summaryrefslogtreecommitdiffstats
path: root/stats/statsaxis.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-18 22:29:34 +0100
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2021-01-20 08:47:18 +0100
commitdb69c38245cc260d19e189716e73dbbbedd56273 (patch)
tree67c08a8e929ab69f5f23b769cd25dc6c280e87cc /stats/statsaxis.cpp
parent9d3de1801e8d14f5143f95042f3b842551d4c4cd (diff)
downloadsubsurface-db69c38245cc260d19e189716e73dbbbedd56273.tar.gz
statistics: refactor QSG memory management
The code was wrong, because it deleted the ChartItems in the main UI thread, not the render thread. This would delete the QSG nodes in the UI thread and then crash on mobile. Therefore refactor this part of the code by adding the items to be deleted to a list that will be deleted by the render thread. As a drop in replacement of std::unique_ptr, implement a silly ChartItemPtr class, which auto-initializes to null. This turns the deterministic and easily controlled memory management into a steaming pile of insanity. Obviously, this can be made much more elegant, but this has to do for now. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/statsaxis.cpp')
-rw-r--r--stats/statsaxis.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/stats/statsaxis.cpp b/stats/statsaxis.cpp
index 5c4f0403e..7af41c14b 100644
--- a/stats/statsaxis.cpp
+++ b/stats/statsaxis.cpp
@@ -159,6 +159,9 @@ void StatsAxis::setSize(double sizeIn)
{
size = sizeIn;
+ // Ticks (and labels) should probably be reused. For now, clear them.
+ for (Tick &tick: ticks)
+ view.deleteChartItem(tick.item);
labels.clear();
ticks.clear();
updateLabels();