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 /core | |
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 'core')
-rw-r--r-- | core/downloadfromdcthread.cpp | 10 | ||||
-rw-r--r-- | core/downloadfromdcthread.h | 6 |
2 files changed, 2 insertions, 14 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp index 67d628d31..34f1eb748 100644 --- a/core/downloadfromdcthread.cpp +++ b/core/downloadfromdcthread.cpp @@ -308,16 +308,6 @@ DCDeviceData *DownloadThread::data() return m_data; } -struct dive_table *DownloadThread::table() -{ - return &downloadTable; -} - -struct dive_site_table *DownloadThread::sites() -{ - return &diveSiteTable; -} - QString DCDeviceData::vendor() const { return data.vendor; diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h index 3a93115db..4284c2cc6 100644 --- a/core/downloadfromdcthread.h +++ b/core/downloadfromdcthread.h @@ -64,13 +64,11 @@ public: void run() override; DCDeviceData *data(); - struct dive_table *table(); - struct dive_site_table *sites(); QString error; - -private: struct dive_table downloadTable; struct dive_site_table diveSiteTable; + +private: DCDeviceData *m_data; }; |