diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-18 22:29:34 +0100 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2021-01-20 08:47:18 +0100 |
commit | db69c38245cc260d19e189716e73dbbbedd56273 (patch) | |
tree | 67c08a8e929ab69f5f23b769cd25dc6c280e87cc /stats/scatterseries.h | |
parent | 9d3de1801e8d14f5143f95042f3b842551d4c4cd (diff) | |
download | subsurface-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/scatterseries.h')
-rw-r--r-- | stats/scatterseries.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/stats/scatterseries.h b/stats/scatterseries.h index d747f3c8d..e1642f4c6 100644 --- a/stats/scatterseries.h +++ b/stats/scatterseries.h @@ -4,6 +4,7 @@ #ifndef SCATTER_SERIES_H #define SCATTER_SERIES_H +#include "statshelper.h" #include "statsseries.h" #include <memory> @@ -32,7 +33,7 @@ private: std::vector<int> getItemsUnderMouse(const QPointF &f) const; struct Item { - std::unique_ptr<ChartScatterItem> item; + ChartItemPtr<ChartScatterItem> item; dive *d; double pos, value; Item(StatsView &view, ScatterSeries *series, dive *d, double pos, double value); @@ -40,7 +41,7 @@ private: void highlight(bool highlight); }; - std::unique_ptr<InformationBox> information; + ChartItemPtr<InformationBox> information; std::vector<Item> items; std::vector<int> highlighted; const StatsVariable &varX; |