summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-10-27 12:35:19 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-10-27 12:37:27 -0700
commit7b4bf883134b49ad177f8970b5d46eb9aecd3b59 (patch)
treeacc6634169766f17d59fe2d6d1ca74f060e28827
parent5888fa07788cd53a3269448e02869143b2c38c45 (diff)
downloadsubsurface-7b4bf883134b49ad177f8970b5d46eb9aecd3b59.tar.gz
Correctly save a re-planned dive
In commit a85a219df325 ("Add ability to replan a dive that we planned before") I completely mishandled the saving of the replanned data. How embarrassing. Fixes #747 See #527 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/diveplanner.cpp8
-rw-r--r--qt-ui/mainwindow.cpp4
2 files changed, 10 insertions, 2 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index b8ca2fb27..d490de3b4 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -1179,9 +1179,15 @@ void DivePlannerPointsModel::createPlan()
//TODO: C-based function here?
plan(&diveplan, &cache, isPlanner(), true);
- if (!current_dive || displayed_dive.id != current_dive->id)
+ if (!current_dive || displayed_dive.id != current_dive->id) {
// we were planning a new dive, not re-planning an existing on
record_dive(clone_dive(&displayed_dive));
+ } else if (current_dive && displayed_dive.id == current_dive->id) {
+ // we are replanning a dive - make sure changes are reflected
+ // correctly in the dive structure and copy it back into the dive table
+ fixup_dive(&displayed_dive);
+ copy_dive(&displayed_dive, current_dive);
+ }
mark_divelist_changed(true);
// Remove and clean the diveplan, so we don't delete
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 53c24a099..0a6112b4f 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -408,6 +408,8 @@ void MainWindow::planCreated()
dive_list()->selectDive(selected_dive);
set_dive_nr_for_current_dive();
}
+ // make sure our UI is in a consistent state
+ ui.InfoWidget->updateDiveInfo();
showProfile();
refreshDisplay();
}
@@ -452,7 +454,7 @@ void MainWindow::on_actionReplanDive_triggered()
if (!plannerStateClean())
return;
if (!current_dive || !current_dive->dc.model || strcmp(current_dive->dc.model, "planned dive")) {
- qDebug() << current_dive->dc.model;
+ qDebug() << "trying to replan a dive that's not a planned dive:" << current_dive->dc.model;
return;
}
ui.ListWidget->endSearch();