From 6fe692bde62ba0c33de006c64a7c5b857bcd4007 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 24 Apr 2014 13:16:57 -0300 Subject: Fix 'cancelling divecomputer download' When a download is canceled, discard the partially downloaded dives. Fixes #341 Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/downloadfromdivecomputer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 26635c6e8..a5b3d617c 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -378,7 +378,13 @@ void DownloadFromDCWidget::onDownloadThreadFinished() } else { process_dives(true, preferDownloaded()); } - } else { + } else if (currentState == CANCELLING || currentState == CANCELLED){ + 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); + } updateState(CANCELLED); } } -- cgit v1.2.3-70-g09d2