Get rid of pointers to dive structures in the UI

The assumption that the pointer will keep pointing to a valid structure is
fundamentally flawed. And even if that is true today, it might change in
the future - just don't do it. Use the diveId instead.

The exception is when you own the structure and use it within one UI
interaction during which any way to change the dive_table is disabled
(e.g., while adding / editing a dive).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-01-07 11:57:20 +08:00
parent 9c617534a0
commit c3fe1a9e9f
5 changed files with 72 additions and 26 deletions

View file

@ -391,7 +391,7 @@ void PrintLayout::printTable()
void PrintLayout::addTablePrintDataRow(TablePrintModel *model, int row, struct dive *dive) const
{
struct DiveItem di;
di.dive = dive;
di.diveId = dive->id;
model->insertRow();
model->setData(model->index(row, 0), QString::number(dive->number), Qt::DisplayRole);
model->setData(model->index(row, 1), di.displayDate(), Qt::DisplayRole);