diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-12-08 06:33:46 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-08 06:33:46 +0100 |
commit | 50a1ed8d6eec849a41026653cc9ce411dcd679bb (patch) | |
tree | 3f498260ca0db4f045abfad9551d398920a1f157 /qt-ui/downloadfromdivecomputer.cpp | |
parent | ad6fab9fb0ba85b3a1f7af28c55248c6230b3f88 (diff) | |
download | subsurface-50a1ed8d6eec849a41026653cc9ce411dcd679bb.tar.gz |
When the user cancels a download, reject already downloaded dives
This seems like the more logical behavior, anyway. Cancel means you didn't
want the result...
Fixes #341
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.cpp')
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 95582efa3..db46b3b72 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -237,6 +237,9 @@ void DownloadFromDCWidget::on_ok_clicked() MainWindow *w = mainWindow(); connect(thread, SIGNAL(finished()), w, SLOT(refreshDisplay())); + // before we start, remember where the dive_table ended + previousLast = dive_table.nr; + thread->start(); } @@ -262,10 +265,18 @@ void DownloadFromDCWidget::onDownloadThreadFinished() updateState(ERROR); // I'm not sure if we should really call process_dives even - // if there's an error or a cancelation - process_dives(TRUE, preferDownloaded()); - } else + // if there's an error + if (import_thread_cancelled) { + // walk backwards so we don't keep moving the dives + // down in the dive_table + for (int i = dive_table.nr - 1; i >= previousLast; i--) + delete_single_dive(i); + } else { + process_dives(TRUE, preferDownloaded()); + } + } else { updateState(CANCELLED); + } } void DownloadFromDCWidget::markChildrenAsDisabled() |