diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-09-22 21:48:46 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-02 08:04:49 -0700 |
commit | 087a80194a54554ab0510a3c2ccc906a448d36ba (patch) | |
tree | 85d52ff0cda47c3c2937ef8e5b1014ad36f7ee66 /qt-models/diveimportedmodel.h | |
parent | a353bcb2961b5c9104097ecf57eeeda4b9e37a9f (diff) | |
download | subsurface-087a80194a54554ab0510a3c2ccc906a448d36ba.tar.gz |
Import: keep dive and dive site tables in DiveImportedModel
The DiveImportedModel and DownloadThread used the same table
of dives and dive sites. This made it very hard to keep the
model consistent: Every modification of the download thread
would make the model inconsistent and could lead to memory
corruption owing to dangling pointers.
Therefore, keep a copy in the model. When updating the model,
use move-semantics, i.e. move the data and reset the tables
of the thread to zero elements.
Since the DiveImportedModel and the DownloadThread are very
tightly integrated, remove the accessor-functions of the
dive and dive-site tables. They fulfilled no purpose
whatsoever as they gave the same access-rights as a public
field.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/diveimportedmodel.h')
-rw-r--r-- | qt-models/diveimportedmodel.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/qt-models/diveimportedmodel.h b/qt-models/diveimportedmodel.h index 468385f6a..2124daef2 100644 --- a/qt-models/diveimportedmodel.h +++ b/qt-models/diveimportedmodel.h @@ -23,6 +23,7 @@ public: QHash<int, QByteArray> roleNames() const; void deleteDeselected(); std::pair<struct dive_table, struct dive_site_table> consumeTables(); // Returns dives and sites and resets model. + int numDives() const; Q_INVOKABLE void recordDives(); Q_INVOKABLE void startDownload(); @@ -43,12 +44,11 @@ signals: void downloadFinished(); private: - void repopulate(dive_table_t *table, dive_site_table_t *sites); int firstIndex; int lastIndex; std::vector<char> checkStates; // char instead of bool to avoid silly pessimization of std::vector. - struct dive_table *diveTable; - struct dive_site_table *sitesTable; + struct dive_table diveTable; + struct dive_site_table sitesTable; }; #endif |