From 9f277e65ffd8c6859f0f7d095289159b7007a061 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 20 Jul 2021 08:17:08 +0200 Subject: cleanup: remove function static variables There were two function-static variables in ToolTipItem::refresh(), which is a very scary proposition. Curently, there is only one ToolTipItem, but this may change on mobile, where there are multiple profiles at the same time. Remove this timebomb and make the two objects subobjects. Signed-off-by: Berthold Stoeger --- profile-widget/divetooltipitem.cpp | 4 ++-- profile-widget/divetooltipitem.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/divetooltipitem.cpp b/profile-widget/divetooltipitem.cpp index 4d8bd5a22..5cc6eecad 100644 --- a/profile-widget/divetooltipitem.cpp +++ b/profile-widget/divetooltipitem.cpp @@ -131,6 +131,8 @@ void ToolTipItem::expand() ToolTipItem::ToolTipItem(QGraphicsItem *parent) : RoundRectItem(8.0, parent), title(new QGraphicsSimpleTextItem(tr("Information"), this)), status(COLLAPSED), + tissues(16,60), + painter(&tissues), timeAxis(0), lastTime(-1) { @@ -219,8 +221,6 @@ void ToolTipItem::setTimeAxis(DiveCartesianAxis *axis) void ToolTipItem::refresh(const dive *d, const QPointF &pos, bool inPlanner) { - static QPixmap tissues(16,60); - static QPainter painter(&tissues); static struct membuffer mb = {}; if(refreshTime.elapsed() < 40) diff --git a/profile-widget/divetooltipitem.h b/profile-widget/divetooltipitem.h index 9a1cdb8bf..ff6218c47 100644 --- a/profile-widget/divetooltipitem.h +++ b/profile-widget/divetooltipitem.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "backend-shared/roundrectitem.h" #include "core/display.h" @@ -48,6 +49,8 @@ private: ToolTip entryToolTip; QGraphicsSimpleTextItem *title; Status status; + QPixmap tissues; + QPainter painter; QRectF rectangle; QRectF nextRectangle; DiveCartesianAxis *timeAxis; -- cgit v1.2.3-70-g09d2