summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-31 14:54:36 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-31 14:57:57 -0700
commite74914fdd0f439d3584657147c81539d2a863955 (patch)
treef25f24ffef40210e085733c90632331cf577404b /qt-ui/profile
parentb9946b89fa3663318ac947778dbf701b1e4ebde0 (diff)
downloadsubsurface-e74914fdd0f439d3584657147c81539d2a863955.tar.gz
Planner: wild guess attempt to fix a crash on Mac
Staring at the stack trace it seems that it gets into an infinite recursion when trying to recalculate after being alerted to a change on the ruler. I cannot recreate this here (not on Linux, not on Mac), but here's a random attempt to prevent the issue: simply refuse to recalculate the ruler while in Add or Plan mode. Crude, but might show us if this really is the issue. Otherwise it's easy enough to revert this change. The qDebug() in there should tell us if people on a Mac do indeed see this even without moving the ruler around in Add or Plan mode. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/profilewidget2.cpp5
-rw-r--r--qt-ui/profile/profilewidget2.h1
-rw-r--r--qt-ui/profile/ruleritem.cpp15
3 files changed, 19 insertions, 2 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index a196b346a..73df4f99d 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -830,6 +830,11 @@ bool ProfileWidget2::isPlanner()
return currentState == PLAN;
}
+bool ProfileWidget2::isAddOrPlanner()
+{
+ return currentState == PLAN || currentState == ADD;
+}
+
void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
{
if (currentState == ADD || currentState == PLAN) {
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index b1a415eb3..9c7610526 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -72,6 +72,7 @@ public:
void setPrintMode(bool mode, bool grayscale = false);
bool isPointOutOfBoundaries(const QPointF &point) const;
bool isPlanner();
+ bool isAddOrPlanner();
State currentState;
public
diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp
index 0f2a24a80..295d81213 100644
--- a/qt-ui/profile/ruleritem.cpp
+++ b/qt-ui/profile/ruleritem.cpp
@@ -1,7 +1,8 @@
#include "ruleritem.h"
#include "divetextitem.h"
#include "profilewidget2.h"
-#include "../preferences.h"
+#include "preferences.h"
+#include "mainwindow.h"
#include <QFont>
#include <QFontMetrics>
@@ -59,9 +60,19 @@ void RulerNodeItem2::recalculate()
QVariant RulerNodeItem2::itemChange(GraphicsItemChange change, const QVariant &value)
{
- if (change == ItemPositionHasChanged) {
+ // only run this if we actually have a ruler and are not adding or planning a dive
+ ProfileWidget2 *profWidget = NULL;
+ if (scene() && scene()->views().count())
+ profWidget = qobject_cast<ProfileWidget2 *>(scene()->views().first());
+ if (ruler &&
+ profWidget &&
+ !profWidget->isAddOrPlanner() &&
+ change == ItemPositionHasChanged) {
recalculate();
ruler->recalculate();
+ } else {
+ if (profWidget && profWidget->isAddOrPlanner())
+ qDebug() << "don't recalc ruler on Add/Plan";
}
return QGraphicsEllipseItem::itemChange(change, value);
}