From a820b20fc2bf91330c6a6351c9f36ba45bf07f13 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 5 Dec 2015 18:27:38 +0200 Subject: [PATCH] The program crashes if scene is not connected to view. --HG-- branch : develop --- .../toolpoint/toolsinglepoint/vtoolbasepoint.cpp | 8 ++++++-- src/libs/vwidgets/vcontrolpointspline.cpp | 8 ++++++-- src/libs/vwidgets/vgraphicssimpletextitem.cpp | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index 42a257796..ec29035b8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -140,9 +140,13 @@ QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, co MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), id, this->scene()); connect(moveSP, &MoveSPoint::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(moveSP); - if (QGraphicsView *view = scene()->views().at(0)) + const QList viewList = scene()->views(); + if (not viewList.isEmpty()) { - view->ensureVisible(this); + if (QGraphicsView *view = viewList.at(0)) + { + view->ensureVisible(this); + } } changeFinished = true; } diff --git a/src/libs/vwidgets/vcontrolpointspline.cpp b/src/libs/vwidgets/vcontrolpointspline.cpp index 4a54037d1..0540cb3a8 100644 --- a/src/libs/vwidgets/vcontrolpointspline.cpp +++ b/src/libs/vwidgets/vcontrolpointspline.cpp @@ -132,9 +132,13 @@ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange chang emit ControlPointChangePosition(indexSpline, position, newPos); if (scene()) { - if (QGraphicsView *view = scene()->views().at(0)) + const QList viewList = scene()->views(); + if (not viewList.isEmpty()) { - view->ensureVisible(this); + if (QGraphicsView *view = viewList.at(0)) + { + view->ensureVisible(this); + } } } changeFinished = true; diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.cpp b/src/libs/vwidgets/vgraphicssimpletextitem.cpp index 028cd3acf..2ff37a5ec 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.cpp +++ b/src/libs/vwidgets/vgraphicssimpletextitem.cpp @@ -126,9 +126,13 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV emit NameChangePosition(newPos); if (scene()) { - if (QGraphicsView *view = scene()->views().at(0)) + const QList viewList = scene()->views(); + if (not viewList.isEmpty()) { - view->ensureVisible(this); + if (QGraphicsView *view = viewList.at(0)) + { + view->ensureVisible(this); + } } } changeFinished = true;