mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Run variations calculation in background
but there are still side effects and thus it crashes. Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
parent
be6b50fce4
commit
a9ceecc2e3
6 changed files with 35 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue