diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-27 15:02:45 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-27 15:12:41 -0700 |
commit | d1cd1eb933418282942b5cdacd1df46b75729f44 (patch) | |
tree | 002a76eb825cc06a104435a57922cbe70a4d69d9 /qt-ui/diveplanner.cpp | |
parent | 7feea7ccfa48c66f71c260fbb4adab889cd988ce (diff) | |
download | subsurface-d1cd1eb933418282942b5cdacd1df46b75729f44.tar.gz |
Planner: better handle the temporary dive used for planning
This still crashes when you abort the plan.
And when you accept the plan, the profile stays stuck in PLAN mode.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index c26aa9569..f6127e5c4 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -247,8 +247,10 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg // Creating the plan connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan())); connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan())); + connect(plannerModel, SIGNAL(planCreated()), MainWindow::instance(), SLOT(removeFakeDiveForAddAndPlan())); connect(plannerModel, SIGNAL(planCreated()), MainWindow::instance(), SLOT(showProfile())); connect(plannerModel, SIGNAL(planCreated()), MainWindow::instance(), SLOT(refreshDisplay())); + connect(plannerModel, SIGNAL(planCanceled()), MainWindow::instance(), SLOT(removeFakeDiveForAddAndPlan())); connect(plannerModel, SIGNAL(planCanceled()), MainWindow::instance(), SLOT(showProfile())); /* set defaults. */ @@ -647,14 +649,17 @@ void DivePlannerPointsModel::cancelPlan() } } clear(); + // we unselected all dives earlier, so restore that first and then recreate the dive list + MainWindow::instance()->dive_list()->restoreSelection(); + MainWindow::instance()->dive_list()->reload(DiveTripModel::CURRENT); + MainWindow::instance()->refreshDisplay(); emit planCanceled(); - if (mode != ADD) + if (mode != ADD) { free(stagingDive); + stagingDive = NULL; + } setPlanMode(NOTHING); - stagingDive = NULL; diveplan.dp = NULL; - CylindersModel::instance()->setDive(current_dive); - CylindersModel::instance()->update(); } DivePlannerPointsModel::Mode DivePlannerPointsModel::currentMode() const @@ -854,6 +859,9 @@ void DivePlannerPointsModel::createPlan() // the dive by mistake. diveplan.dp = NULL; clear(); + + // we unselected all dives earlier, so as a side effect recreating the dive list will select the new dive + MainWindow::instance()->recreateDiveList(); planCreated(); setPlanMode(NOTHING); free(stagingDive); |