summaryrefslogtreecommitdiffstats
path: root/qt-ui/models.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-07 11:57:20 +0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-07 12:10:19 +0800
commitc3fe1a9e9f79c77c533642df4f986238ef08452b (patch)
tree38236bef570eb5e955a6b8470e62a2917b706b34 /qt-ui/models.h
parent9c617534a050ec0a0afd84ef578d7c6d0e800a59 (diff)
downloadsubsurface-c3fe1a9e9f79c77c533642df4f986238ef08452b.tar.gz
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>
Diffstat (limited to 'qt-ui/models.h')
-rw-r--r--qt-ui/models.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/qt-ui/models.h b/qt-ui/models.h
index baa7b32c4..1f1641e16 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -101,7 +101,7 @@ public slots:
void remove(const QModelIndex& index);
private:
- struct dive *current;
+ int currentId;
int rows;
};
@@ -130,7 +130,7 @@ public slots:
void remove(const QModelIndex& index);
private:
- struct dive *current;
+ int currentId;
int rows;
};
@@ -157,7 +157,7 @@ struct DiveItem : public TreeItem {
SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS };
virtual QVariant data(int column, int role) const;
- struct dive* dive;
+ int diveId;
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
QString displayDate() const;
@@ -291,7 +291,7 @@ class ProfilePrintModel : public QAbstractTableModel
Q_OBJECT
private:
- struct dive *dive;
+ int diveId;
QString truncateString(char *str, const int maxlen) const;
public: