Commit d0002a9c authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.formEditor: crash fix

We have to Guard events. The Formeditor has to be fully initialized.

Task-Nr: QTCREATORBUG-4225
parent e785831d
...@@ -197,9 +197,12 @@ void FormEditorScene::synchronizeOtherProperty(const QmlItemNode &qmlItemNode, c ...@@ -197,9 +197,12 @@ void FormEditorScene::synchronizeOtherProperty(const QmlItemNode &qmlItemNode, c
if (propertyName == "clip") if (propertyName == "clip")
item->setFlag(QGraphicsItem::ItemClipsChildrenToShape, qmlItemNode.instanceValue("clip").toBool()); item->setFlag(QGraphicsItem::ItemClipsChildrenToShape, qmlItemNode.instanceValue("clip").toBool());
if (propertyName == "visible") if (!qmlItemNode.isRootNode()) {
item->setContentVisible(qmlItemNode.instanceValue("visible").toBool()); if (propertyName == "visible")
item->setContentVisible(qmlItemNode.instanceValue("visible").toBool());
} else {
item->setContentVisible(true);
}
} }
} }
...@@ -268,7 +271,9 @@ QList<QGraphicsItem *> FormEditorScene::removeLayerItems(const QList<QGraphicsIt ...@@ -268,7 +271,9 @@ QList<QGraphicsItem *> FormEditorScene::removeLayerItems(const QList<QGraphicsIt
void FormEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *event) void FormEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
currentTool()->mousePressEvent(removeLayerItems(items(event->scenePos())), event); if (editorView() && editorView()->model()) {
currentTool()->mousePressEvent(removeLayerItems(items(event->scenePos())), event);
}
} }
void FormEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void FormEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...@@ -283,26 +288,34 @@ void FormEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) ...@@ -283,26 +288,34 @@ void FormEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void FormEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void FormEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
currentTool()->mouseReleaseEvent(removeLayerItems(items(event->scenePos())), event); if (editorView() && editorView()->model()) {
currentTool()->mouseReleaseEvent(removeLayerItems(items(event->scenePos())), event);
event->accept(); event->accept();
}
} }
void FormEditorScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void FormEditorScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{ {
currentTool()->mouseDoubleClickEvent(removeLayerItems(items(event->scenePos())), event); if (editorView() && editorView()->model()) {
currentTool()->mouseDoubleClickEvent(removeLayerItems(items(event->scenePos())), event);
event->accept(); event->accept();
}
} }
void FormEditorScene::keyPressEvent(QKeyEvent *keyEvent) void FormEditorScene::keyPressEvent(QKeyEvent *keyEvent)
{ {
currentTool()->keyPressEvent(keyEvent); if (editorView() && editorView()->model()) {
currentTool()->keyPressEvent(keyEvent);
}
} }
void FormEditorScene::keyReleaseEvent(QKeyEvent *keyEvent) void FormEditorScene::keyReleaseEvent(QKeyEvent *keyEvent)
{ {
currentTool()->keyReleaseEvent(keyEvent); if (editorView() && editorView()->model()) {
currentTool()->keyReleaseEvent(keyEvent);
}
} }
FormEditorView *FormEditorScene::editorView() const FormEditorView *FormEditorScene::editorView() const
......
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