From 235146a95f5d79c54cf3b68b490c1cb0fb146b5f Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 9 Jan 2021 21:18:37 +0100 Subject: profile: pass dive to DiveHandler The DiveHandler shows a context menu where a cylinder can be chosen. This indirectly accesses the global displayed_dive variable. Remove this in a step to make the profile reentrant. The code was quite ominous: instead of simply generating the list of cylinders, a global model was reset and then accessed with Qt's cumbersome model/view API. All this trampling over global state can be removed by simply making the function that generates the list globally accessible. Signed-off-by: Berthold Stoeger --- profile-widget/divehandler.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'profile-widget/divehandler.h') diff --git a/profile-widget/divehandler.h b/profile-widget/divehandler.h index ecd0248c8..2bf3527ac 100644 --- a/profile-widget/divehandler.h +++ b/profile-widget/divehandler.h @@ -5,10 +5,12 @@ #include #include +struct dive; + class DiveHandler : public QObject, public QGraphicsEllipseItem { Q_OBJECT public: - DiveHandler(); + DiveHandler(const struct dive *d); protected: void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); @@ -26,6 +28,7 @@ slots: void selfRemove(); void changeGas(); private: + const struct dive *dive; QElapsedTimer t; }; -- cgit v1.2.3-70-g09d2