mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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>
This commit is contained in:
parent
b9946b89fa
commit
e74914fdd0
3 changed files with 19 additions and 2 deletions
|
@ -830,6 +830,11 @@ bool ProfileWidget2::isPlanner()
|
||||||
return currentState == PLAN;
|
return currentState == PLAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProfileWidget2::isAddOrPlanner()
|
||||||
|
{
|
||||||
|
return currentState == PLAN || currentState == ADD;
|
||||||
|
}
|
||||||
|
|
||||||
void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
|
void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
if (currentState == ADD || currentState == PLAN) {
|
if (currentState == ADD || currentState == PLAN) {
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
void setPrintMode(bool mode, bool grayscale = false);
|
void setPrintMode(bool mode, bool grayscale = false);
|
||||||
bool isPointOutOfBoundaries(const QPointF &point) const;
|
bool isPointOutOfBoundaries(const QPointF &point) const;
|
||||||
bool isPlanner();
|
bool isPlanner();
|
||||||
|
bool isAddOrPlanner();
|
||||||
State currentState;
|
State currentState;
|
||||||
|
|
||||||
public
|
public
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include "ruleritem.h"
|
#include "ruleritem.h"
|
||||||
#include "divetextitem.h"
|
#include "divetextitem.h"
|
||||||
#include "profilewidget2.h"
|
#include "profilewidget2.h"
|
||||||
#include "../preferences.h"
|
#include "preferences.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
|
@ -59,9 +60,19 @@ void RulerNodeItem2::recalculate()
|
||||||
|
|
||||||
QVariant RulerNodeItem2::itemChange(GraphicsItemChange change, const QVariant &value)
|
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();
|
recalculate();
|
||||||
ruler->recalculate();
|
ruler->recalculate();
|
||||||
|
} else {
|
||||||
|
if (profWidget && profWidget->isAddOrPlanner())
|
||||||
|
qDebug() << "don't recalc ruler on Add/Plan";
|
||||||
}
|
}
|
||||||
return QGraphicsEllipseItem::itemChange(change, value);
|
return QGraphicsEllipseItem::itemChange(change, value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue