From a4ca3c520c7fbae5d1739a88e928a60585676ade Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 14 Oct 2019 20:21:15 +0200 Subject: 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 --- desktop-widgets/tab-widgets/maintab.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'desktop-widgets/tab-widgets') 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 &dives, DiveField field) @@ -316,7 +304,7 @@ void MainTab::divesChanged(const QVector &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) -- cgit v1.2.3-70-g09d2