From db69c38245cc260d19e189716e73dbbbedd56273 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 18 Jan 2021 22:29:34 +0100 Subject: 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 --- stats/statsaxis.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'stats/statsaxis.h') diff --git a/stats/statsaxis.h b/stats/statsaxis.h index 89c9edbe2..02662ddd9 100644 --- a/stats/statsaxis.h +++ b/stats/statsaxis.h @@ -3,6 +3,7 @@ #define STATS_AXIS_H #include "chartitem.h" +#include "statshelper.h" #include #include @@ -36,7 +37,7 @@ public: protected: StatsAxis(StatsView &view, const QString &title, bool horizontal, bool labelsBetweenTicks); - std::unique_ptr line; + ChartItemPtr line; QString title; double titleWidth; @@ -51,7 +52,7 @@ protected: virtual std::pair getFirstLastLabel() const = 0; struct Tick { - std::unique_ptr item; + ChartItemPtr item; double pos; }; std::vector ticks; -- cgit v1.2.3-70-g09d2