Commit 14cf477e authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.ContextMenu: Crash fix



The root item cannot be "filled".
Adding a try catch block just in case.

Task-number: QTCREATORBUG-10476
Change-Id: Ic5c5efddd78194275d7d6e393eb945d6c9d89ed0
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 2d78805b
......@@ -269,6 +269,12 @@ bool selectionNotEmptyAndHasWidthOrHeightProperty(const SelectionContext &contex
&& selectionHasProperty1or2(context, widthProperty, heightProperty);
}
bool singleSelectionItemIsNotAnchoredAndSingleSelectionNotRoot(const SelectionContext &context)
{
return singleSelectionItemIsNotAnchored(context)
&& singleSelectionNotRoot(context);
}
bool selectionNotEmptyAndHasXorYProperty(const SelectionContext &context)
{
return selectionNotEmpty(context)
......@@ -335,7 +341,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new MenuDesignerAction(anchorsCategoryDisplayName, anchorsCategory,
priorityAnchorsCategory, &singleSelectionAndInBaseState));
addDesignerAction(new ModelNodeAction
(anchorsFillDisplayName, anchorsCategory, 200, &anchorsFill, &singleSelectionItemIsNotAnchored));
(anchorsFillDisplayName, anchorsCategory, 200, &anchorsFill, &singleSelectionItemIsNotAnchoredAndSingleSelectionNotRoot));
addDesignerAction(new ModelNodeAction
(anchorsResetDisplayName, anchorsCategory, 180, &anchorsReset, &singleSelectionItemIsAnchored));
......
......@@ -373,17 +373,23 @@ void anchorsFill(const SelectionContext &selectionState)
if (!selectionState.view())
return;
RewriterTransaction transaction(selectionState.view());
try {
RewriterTransaction transaction(selectionState.view());
ModelNode modelNode = selectionState.currentSingleSelectedNode();
ModelNode modelNode = selectionState.currentSingleSelectedNode();
QmlItemNode node = modelNode;
if (node.isValid()) {
node.anchors().fill();
backupPropertyAndRemove(modelNode, "x");
backupPropertyAndRemove(modelNode, "y");
backupPropertyAndRemove(modelNode, "width");
backupPropertyAndRemove(modelNode, "height");
QmlItemNode node = modelNode;
if (node.isValid()) {
node.anchors().fill();
backupPropertyAndRemove(modelNode, "x");
backupPropertyAndRemove(modelNode, "y");
backupPropertyAndRemove(modelNode, "width");
backupPropertyAndRemove(modelNode, "height");
}
transaction.commit();
} catch (RewritingException &e) { //better save then sorry
QMessageBox::warning(0, "Error", e.description());
}
}
......
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