mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
2778470b97
Tank icons were shown at incorrect spots on the profile when the DiveEventItem object held a pointer to a struct event even after the struct event at that address had been freed. When internalEvent is a pointer to freed memory, internalEvent->time.seconds could have all kinds of crazy values, which get used in member function DiveEventItem::recalculatePos to place the tank at bad x coordinates. The DiveEventItem(s) no longer store a pointer to memory that they do not own. This way, no matter how the path of execution arrives into slot recalculatePos, we never need fear that the DiveEventItem will dereference a garbage pointer to a struct event. Fixes #968 Signed-off-by: K. Heller <pestophagous@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
35 lines
828 B
C++
35 lines
828 B
C++
#ifndef DIVEEVENTITEM_H
|
|
#define DIVEEVENTITEM_H
|
|
|
|
#include "divepixmapitem.h"
|
|
|
|
class DiveCartesianAxis;
|
|
class DivePlotDataModel;
|
|
struct event;
|
|
|
|
class DiveEventItem : public DivePixmapItem {
|
|
Q_OBJECT
|
|
public:
|
|
DiveEventItem(QObject *parent = 0);
|
|
virtual ~DiveEventItem();
|
|
void setEvent(struct event *ev);
|
|
struct event *getEvent();
|
|
void eventVisibilityChanged(const QString &eventName, bool visible);
|
|
void setVerticalAxis(DiveCartesianAxis *axis);
|
|
void setHorizontalAxis(DiveCartesianAxis *axis);
|
|
void setModel(DivePlotDataModel *model);
|
|
bool shouldBeHidden();
|
|
public
|
|
slots:
|
|
void recalculatePos(bool instant = false);
|
|
|
|
private:
|
|
void setupToolTipString();
|
|
void setupPixmap();
|
|
DiveCartesianAxis *vAxis;
|
|
DiveCartesianAxis *hAxis;
|
|
DivePlotDataModel *dataModel;
|
|
struct event *internalEvent;
|
|
};
|
|
|
|
#endif // DIVEEVENTITEM_H
|