diff options
-rw-r--r-- | desktop-widgets/downloadfromdivecomputer.cpp | 2 | ||||
-rw-r--r-- | qt-models/diveimportedmodel.cpp | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index 2d834359e..5400f62ed 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -421,6 +421,8 @@ void DownloadFromDCWidget::on_ok_clicked() for (int i = 0; i < downloadTable.nr; i++) { if (diveImportedModel->data(diveImportedModel->index(i, 0),Qt::CheckStateRole) == Qt::Checked) record_dive(downloadTable.dives[i]); + else + clear_dive(downloadTable.dives[i]); downloadTable.dives[i] = NULL; } downloadTable.nr = 0; diff --git a/qt-models/diveimportedmodel.cpp b/qt-models/diveimportedmodel.cpp index 1b8b5a897..f121aef31 100644 --- a/qt-models/diveimportedmodel.cpp +++ b/qt-models/diveimportedmodel.cpp @@ -148,11 +148,18 @@ void DiveImportedModel::repopulate() void DiveImportedModel::recordDives() { + // walk the table of imported dives and record the ones that the user picked + // clearing out the table as we go for (int i = 0; i < rowCount(); i++) { - if (diveTable->dives[i] && checkStates[i]) { - record_dive(diveTable->dives[i]); - diveTable->dives[i] = NULL; + struct dive *d = diveTable->dives[i]; + if (d && checkStates[i]) { + record_dive(d); + } else { + // we should free the dives that weren't recorded + clear_dive(d); + free(d) } + diveTable->dives[i] = NULL; } diveTable->nr = 0; } |