Commit da3a1568 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.DragAndDrop: Catch rewriter exception

The designer should not crash if there is an issue with rewriting.

Change-Id: I0c1af386e9733349fa4ef9896588f8ea3d2eaed6
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent c7f35c63
......@@ -81,7 +81,7 @@ void DragTool::keyPressEvent(QKeyEvent *event)
if (event->key() == Qt::Key_Escape) {
abort();
event->accept();
m_rewriterTransaction.commit();
commitTransaction();
view()->changeToSelectionTool();
}
}
......@@ -232,7 +232,7 @@ void DragTool::dropEvent(const QList<QGraphicsItem*> &/*itemList*/, QGraphicsSce
event->accept();
end(generateUseSnapping(event->modifiers()));
m_rewriterTransaction.commit();
commitTransaction();
if (m_dragNode.isValid())
view()->setSelectedModelNode(m_dragNode);
......@@ -282,7 +282,7 @@ void DragTool::dragLeaveEvent(const QList<QGraphicsItem*> &/*itemList*/, QGraphi
if (m_dragNode.isValid())
m_dragNode.destroy();
m_rewriterTransaction.commit();
commitTransaction();
view()->changeToSelectionTool();
}
......@@ -361,4 +361,13 @@ void DragTool::move(const QPointF &scenePosition, const QList<QGraphicsItem*> &
}
}
void DragTool::commitTransaction()
{
try {
m_rewriterTransaction.commit();
} catch (RewritingException &e) {
e.showException();
}
}
}
......@@ -91,6 +91,7 @@ protected:
void end(Snapper::Snapping useSnapping);
void move(const QPointF &scenePos, const QList<QGraphicsItem *> &itemList);
void createDragNode(const QMimeData *mimeData, const QPointF &scenePosition, const QList<QGraphicsItem *> &itemList);
void commitTransaction();
private:
MoveManipulator m_moveManipulator;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment