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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-07-20 08:17:08 +02:00 committed by Dirk Hohndel
parent 82f967ddb3
commit 9f277e65ff
2 changed files with 5 additions and 2 deletions

View file

@ -131,6 +131,8 @@ void ToolTipItem::expand()
ToolTipItem::ToolTipItem(QGraphicsItem *parent) : RoundRectItem(8.0, parent), ToolTipItem::ToolTipItem(QGraphicsItem *parent) : RoundRectItem(8.0, parent),
title(new QGraphicsSimpleTextItem(tr("Information"), this)), title(new QGraphicsSimpleTextItem(tr("Information"), this)),
status(COLLAPSED), status(COLLAPSED),
tissues(16,60),
painter(&tissues),
timeAxis(0), timeAxis(0),
lastTime(-1) lastTime(-1)
{ {
@ -219,8 +221,6 @@ void ToolTipItem::setTimeAxis(DiveCartesianAxis *axis)
void ToolTipItem::refresh(const dive *d, const QPointF &pos, bool inPlanner) void ToolTipItem::refresh(const dive *d, const QPointF &pos, bool inPlanner)
{ {
static QPixmap tissues(16,60);
static QPainter painter(&tissues);
static struct membuffer mb = {}; static struct membuffer mb = {};
if(refreshTime.elapsed() < 40) if(refreshTime.elapsed() < 40)

View file

@ -7,6 +7,7 @@
#include <QRectF> #include <QRectF>
#include <QIcon> #include <QIcon>
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QPainter>
#include "backend-shared/roundrectitem.h" #include "backend-shared/roundrectitem.h"
#include "core/display.h" #include "core/display.h"
@ -48,6 +49,8 @@ private:
ToolTip entryToolTip; ToolTip entryToolTip;
QGraphicsSimpleTextItem *title; QGraphicsSimpleTextItem *title;
Status status; Status status;
QPixmap tissues;
QPainter painter;
QRectF rectangle; QRectF rectangle;
QRectF nextRectangle; QRectF nextRectangle;
DiveCartesianAxis *timeAxis; DiveCartesianAxis *timeAxis;