From bd7ded88940995ebbb46fc6983ba9cfd179e55e0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 30 Nov 2013 09:18:03 -0800 Subject: Delete the graphics items for the ticks and labels in the ruler Ruler::updateTicks() was creating them, but nothing deleted them. Signed-off-by: Thiago Macieira Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 18 ++++++++++++++---- qt-ui/diveplanner.h | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 5efac70a9..b18f56bd6 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -770,10 +770,23 @@ void Ruler::setTextColor(const QColor& color) textColor = color; } +void Ruler::eraseAll() +{ + qDeleteAll(ticks); + ticks.clear(); + qDeleteAll(labels); + labels.clear(); +} + Ruler::Ruler() : orientation(Qt::Horizontal) { } +Ruler::~Ruler() +{ + eraseAll(); +} + void Ruler::setOrientation(Qt::Orientation o) { orientation = o; @@ -784,10 +797,7 @@ void Ruler::setOrientation(Qt::Orientation o) void Ruler::updateTicks() { - qDeleteAll(ticks); - ticks.clear(); - qDeleteAll(labels); - labels.clear(); + eraseAll(); QLineF m = line(); QGraphicsLineItem *item = NULL; diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 81e36b02c..bc6f696ad 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -125,6 +125,7 @@ public slots: class Ruler : public QGraphicsLineItem{ public: Ruler(); + ~Ruler(); void setMinimum(double minimum); void setMaximum(double maximum); void setTickInterval(double interval); @@ -141,6 +142,8 @@ public: int unitSystem; private: + void eraseAll(); + Qt::Orientation orientation; QList ticks; QList labels; -- cgit v1.2.3-70-g09d2