diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-10-14 20:21:15 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-26 11:36:23 -0700 |
commit | a4ca3c520c7fbae5d1739a88e928a60585676ade (patch) | |
tree | e1479707f3baa70eb10841201583050c83b672c5 /desktop-widgets/tab-widgets | |
parent | 8dea2ada3bc9d0fcfbe1bb101ea079480dfdbe57 (diff) | |
download | subsurface-a4ca3c520c7fbae5d1739a88e928a60585676ade.tar.gz |
Undo: simplify profile repainting code
The profile repainting code that was called when a dive changed was
located in a separate function. Not only did it take a redundant
parameter, it also performed very weird stuff like entering and
exiting plan state. That did not work at all. Replace by a simple
call to plotDive() and things work much better.
There was a comment about DivePlannerPointsModel and profile
getting out of sync. So let's keep an eye out for that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 9fe647a71..3418fbddd 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -264,18 +264,6 @@ void MainTab::enableEdition(EditMode newEditMode) editMode = newEditMode != NONE ? newEditMode : DIVE; } -static void profileFromDive(struct dive *d) -{ - // TODO: We have to put these manipulations into a setPlanState()/setProfileState() pair, - // because otherwise the DivePlannerPointsModel and the profile get out of sync. - // This can lead to crashes. Let's try to detangle these subtleties. - MainWindow::instance()->graphics->setPlanState(); - DivePlannerPointsModel::instance()->loadFromDive(d); - MainWindow::instance()->graphics->setReplot(true); - MainWindow::instance()->graphics->plotDive(current_dive, true); - MainWindow::instance()->graphics->setProfileState(); -} - // This function gets called if a field gets updated by an undo command. // Refresh the corresponding UI field. void MainTab::divesChanged(const QVector<dive *> &dives, DiveField field) @@ -316,7 +304,7 @@ void MainTab::divesChanged(const QVector<dive *> &dives, DiveField field) // If duration or depth changed, the profile needs to be replotted if (field.duration || field.depth) - profileFromDive(current_dive); + MainWindow::instance()->graphics->plotDive(current_dive, true); } void MainTab::diveSiteEdited(dive_site *ds, int) |