QmlDesigner.ContextMenu: Fixing possible crash

If an item is created but not (yet) in the hierarchy, but gets selected,
the parent property is not valid. We should check for this case.

Change-Id: I965bc20172bfd58b0b1759d3b0907971dfe142f1
Reviewed-by: Marco Bubke <marco.bubke@digia.com>
This commit is contained in:
Thomas Hartmann
2014-03-05 15:44:53 +01:00
parent 521bb9156e
commit 37e603bcd9

View File

@@ -158,7 +158,10 @@ public:
} }
if (m_action->isEnabled()) { if (m_action->isEnabled()) {
ModelNode parentNode; ModelNode parentNode;
if (m_selectionContext.singleNodeIsSelected() && !m_selectionContext.currentSingleSelectedNode().isRootNode()) { if (m_selectionContext.singleNodeIsSelected()
&& !m_selectionContext.currentSingleSelectedNode().isRootNode()
&& m_selectionContext.currentSingleSelectedNode().hasParentProperty()) {
ActionTemplate *selectionAction = new ActionTemplate(QString(), &ModelNodeOperations::select); ActionTemplate *selectionAction = new ActionTemplate(QString(), &ModelNodeOperations::select);
selectionAction->setParent(m_menu.data()); selectionAction->setParent(m_menu.data());