summaryrefslogtreecommitdiffstats
path: root/qt-models/diveplannermodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models/diveplannermodel.cpp')
-rw-r--r--qt-models/diveplannermodel.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 127ea8649..acf2d9c6f 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -9,6 +9,7 @@
#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include <QApplication>
#include <QTextDocument>
+#include <QtConcurrent>
#define UNIT_FACTOR ((prefs.units.length == units::METERS) ? 1000.0 / 60.0 : feet_to_mm(1.0) / 60.0)
@@ -920,7 +921,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
if (recalcQ() && !diveplan_empty(&diveplan)) {
struct decostop stoptable[60];
plan(&diveplan, &displayed_dive, DECOTIMESTEP, stoptable, &cache, isPlanner(), false);
- computeVariations();
+ QtConcurrent::run(this, &DivePlannerPointsModel::computeVariations);
emit calculatedPlanNotes();
}
// throw away the cache
@@ -1013,8 +1014,11 @@ void DivePlannerPointsModel::computeVariations()
struct divedatapoint *last_segment;
if(in_planner() && prefs.display_variations) {
+ int my_instance = ++instanceCounter;
cache_deco_state(&save);
cloneDiveplan(&plan_copy);
+ if (my_instance != instanceCounter)
+ return;
plan(&plan_copy, dive, 1, original, &cache, true, false);
free_dps(&plan_copy);
restore_deco_state(save, false);
@@ -1022,6 +1026,8 @@ void DivePlannerPointsModel::computeVariations()
last_segment = cloneDiveplan(&plan_copy);
last_segment->depth.mm += 1000;
last_segment->next->depth.mm += 1000;
+ if (my_instance != instanceCounter)
+ return;
plan(&plan_copy, dive, 1, deeper, &cache, true, false);
free_dps(&plan_copy);
restore_deco_state(save, false);
@@ -1029,18 +1035,24 @@ void DivePlannerPointsModel::computeVariations()
last_segment = cloneDiveplan(&plan_copy);
last_segment->depth.mm -= 1000;
last_segment->next->depth.mm -= 1000;
+ if (my_instance != instanceCounter)
+ return;
plan(&plan_copy, dive, 1, shallower, &cache, true, false);
free_dps(&plan_copy);
restore_deco_state(save, false);
last_segment = cloneDiveplan(&plan_copy);
last_segment->next->time += 60;
+ if (my_instance != instanceCounter)
+ return;
plan(&plan_copy, dive, 1, longer, &cache, true, false);
free_dps(&plan_copy);
restore_deco_state(save, false);
last_segment = cloneDiveplan(&plan_copy);
last_segment->next->time -= 60;
+ if (my_instance != instanceCounter)
+ return;
plan(&plan_copy, dive, 1, shorter, &cache, true, false);
free_dps(&plan_copy);
restore_deco_state(save, false);