mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Planner: copy deco state before passing it to worker thread
The planner has a computeVariations() function that can be run in a worker thread. The code was not thread safe: a deco_state object allocated on the stack of the caller was passed down to the worker thread. It's well possible that the object would go out of scope before the thread run. Therefore, when running in the background, copy the object first and free it in the worker thread. Side note: Qt makes proper memory management again as difficult as possible: You can't pass a std::unique_ptr<> to QtConcurrent::run, because move-only objects are not supported. Not very friendly! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f7c8d65add
commit
769403a4b2
2 changed files with 14 additions and 4 deletions
|
|
@ -117,7 +117,8 @@ private:
|
|||
void createPlan(bool replanCopy);
|
||||
struct diveplan diveplan;
|
||||
struct divedatapoint *cloneDiveplan(struct diveplan *plan_src, struct diveplan *plan_copy);
|
||||
void computeVariations(struct diveplan *diveplan, struct deco_state *ds);
|
||||
void computeVariations(struct diveplan *diveplan, const struct deco_state *ds);
|
||||
void computeVariationsFreeDeco(struct diveplan *diveplan, struct deco_state *ds);
|
||||
int analyzeVariations(struct decostop *min, struct decostop *mid, struct decostop *max, const char *unit);
|
||||
Mode mode;
|
||||
bool recalc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue