aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@digia.com>2014-01-17 10:09:23 +0100
committerThomas Hartmann <Thomas.Hartmann@digia.com>2014-01-17 10:13:02 +0100
commit14cf477e3133b3564eedd1040c072e3dfe1fa8d3 (patch)
tree1c87770367ca816e50458019e614219b924a63e2 /src
parent2d78805b9be4b709c7f63357fba7e5da1ffd6662 (diff)
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: Thomas Hartmann <Thomas.Hartmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp8
-rw-r--r--src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp24
2 files changed, 22 insertions, 10 deletions
diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
index 52b4c8904d..53ca0feee3 100644
--- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
@@ -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));
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
index 405f4c6d17..2cf7ff2d80 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
@@ -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());
}
}