diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-03-07 12:08:31 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-03-07 08:53:14 -0800 |
commit | 6dec4b055601526a0c8bf9e45dfe0ff648d80489 (patch) | |
tree | b7c2207f2e6b0e218beb9e8e53fad779adb97498 /qt-ui/profile/ruleritem.cpp | |
parent | 80341062195b27ea2f6d16ef22225b439ac84165 (diff) | |
download | subsurface-6dec4b055601526a0c8bf9e45dfe0ff648d80489.tar.gz |
Fix a crash on changing dives when the ruler is used.
The ruler is a weird beast - it has two child objects that access the
parent to call another function, that call the child functions.
When I updated the plot_info I didn't take that into consideration, what
happened is that when I set the parent's plot_info, the children's
plot_info are still invalid, but the update method is called anyhow.
This patch updates all plot_info's before calling anything else.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/ruleritem.cpp')
-rw-r--r-- | qt-ui/profile/ruleritem.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp index 042742a23..a21a9a04a 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/qt-ui/profile/ruleritem.cpp @@ -13,8 +13,9 @@ #include "profile.h" #include "display.h" -RulerNodeItem2::RulerNodeItem2(struct plot_info &info) : pInfo(info), entry(NULL), ruler(NULL) +RulerNodeItem2::RulerNodeItem2() : entry(NULL), ruler(NULL) { + memset(&pInfo, 0, sizeof(pInfo)); setRect(QRect(QPoint(-8, 8), QPoint(8, -8))); setBrush(QColor(0xff, 0, 0, 127)); setPen(QColor("#FF0000")); @@ -23,6 +24,12 @@ RulerNodeItem2::RulerNodeItem2(struct plot_info &info) : pInfo(info), entry(NULL setFlag(ItemIgnoresTransformations); } +void RulerNodeItem2::setPlotInfo(plot_info& info) +{ + pInfo = info; + entry = pInfo.entry; +} + void RulerNodeItem2::setRuler(RulerItem2 *r) { ruler = r; @@ -54,17 +61,14 @@ QVariant RulerNodeItem2::itemChange(GraphicsItemChange change, const QVariant &v recalculate(); if (ruler != NULL) ruler->recalculate(); - if (scene()) { - scene()->update(); - } } return QGraphicsEllipseItem::itemChange(change, value); } RulerItem2::RulerItem2() : timeAxis(NULL), depthAxis(NULL), - source(new RulerNodeItem2(pInfo)), - dest(new RulerNodeItem2(pInfo)), + source(new RulerNodeItem2()), + dest(new RulerNodeItem2()), textItem(new QGraphicsSimpleTextItem(this)) { memset(&pInfo, 0, sizeof(pInfo)); @@ -157,9 +161,11 @@ QPainterPath RulerItem2::shape() const void RulerItem2::setPlotInfo(plot_info info) { pInfo = info; - recalculate(); + dest->setPlotInfo(info); + source->setPlotInfo(info); dest->recalculate(); source->recalculate(); + recalculate(); } void RulerItem2::setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth) |