aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@nokia.com>2011-08-22 17:01:02 +0200
committerThomas Hartmann <Thomas.Hartmann@nokia.com>2011-08-22 17:09:21 +0200
commitc85ebaca9d42a6c158f74843e6119675c6e0d8e8 (patch)
treeeb8b1b6d9857ab105f88975f500413aee4714670 /src
parent78e96d743342b9270249f29ff1c266b638d93a84 (diff)
QmlDesigner.propertyEditor: crash fix
If the anchor target does not have a corresponding model node we had a crash. This happens for e.g. Flickable because children is redefined. Task-number: QTCREATORBUG-5829 Change-Id: Ib3f609fe7c29778dd4fdd8ed1ac8526afbb36fe0 Reviewed-on: http://codereview.qt.nokia.com/3327 Reviewed-by: Marco Bubke <marco.bubke@nokia.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp84
1 files changed, 60 insertions, 24 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
index 41a01e0209..bb33ab26dc 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
@@ -82,23 +82,41 @@ void QmlAnchorBindingProxy::setup(const QmlItemNode &fxItemNode)
m_verticalTarget = m_horizontalTarget = m_topTarget = m_bottomTarget = m_leftTarget = m_rightTarget = m_fxItemNode.modelNode().parentProperty().parentModelNode();
- if (topAnchored())
- m_topTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Top).qmlItemNode();
+ if (topAnchored()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Top).qmlItemNode();
+ if (targetNode.isValid())
+ m_topTarget = targetNode;
+ }
- if (bottomAnchored())
- m_bottomTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Bottom).qmlItemNode();
+ if (bottomAnchored()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Bottom).qmlItemNode();
+ if (targetNode.isValid())
+ m_bottomTarget = targetNode;
+ }
- if (leftAnchored())
- m_leftTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Left).qmlItemNode();
+ if (leftAnchored()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Left).qmlItemNode();
+ if (targetNode.isValid())
+ m_leftTarget = targetNode;
+ }
- if (rightAnchored())
- m_rightTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Right).qmlItemNode();
+ if (rightAnchored()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Right).qmlItemNode();
+ if (targetNode.isValid())
+ m_rightTarget = targetNode;
+ }
- if (verticalCentered())
- m_verticalTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::VerticalCenter).qmlItemNode();
+ if (verticalCentered()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::VerticalCenter).qmlItemNode();
+ if (targetNode.isValid())
+ m_verticalTarget = targetNode;
+ }
- if (horizontalCentered())
- m_horizontalTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::HorizontalCenter).qmlItemNode();
+ if (horizontalCentered()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::HorizontalCenter).qmlItemNode();
+ if (targetNode.isValid())
+ m_horizontalTarget = targetNode;
+ }
emit itemNodeChanged();
emit parentChanged();
@@ -130,23 +148,41 @@ void QmlAnchorBindingProxy::invalidate(const QmlItemNode &fxItemNode)
m_verticalTarget = m_horizontalTarget = m_topTarget = m_bottomTarget = m_leftTarget = m_rightTarget = m_fxItemNode.modelNode().parentProperty().parentModelNode();
- if (topAnchored())
- m_topTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Top).qmlItemNode();
+ if (topAnchored()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Top).qmlItemNode();
+ if (targetNode.isValid())
+ m_topTarget = targetNode;
+ }
- if (bottomAnchored())
- m_bottomTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Bottom).qmlItemNode();
+ if (bottomAnchored()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Bottom).qmlItemNode();
+ if (targetNode.isValid())
+ m_bottomTarget = targetNode;
+ }
- if (leftAnchored())
- m_leftTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Left).qmlItemNode();
+ if (leftAnchored()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Left).qmlItemNode();
+ if (targetNode.isValid())
+ m_leftTarget = targetNode;
+ }
- if (rightAnchored())
- m_rightTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Right).qmlItemNode();
+ if (rightAnchored()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Right).qmlItemNode();
+ if (targetNode.isValid())
+ m_rightTarget = targetNode;
+ }
- if (verticalCentered())
- m_verticalTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::VerticalCenter).qmlItemNode();
+ if (verticalCentered()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::VerticalCenter).qmlItemNode();
+ if (targetNode.isValid())
+ m_verticalTarget = targetNode;
+ }
- if (horizontalCentered())
- m_horizontalTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::HorizontalCenter).qmlItemNode();
+ if (horizontalCentered()) {
+ ModelNode targetNode = m_fxItemNode.anchors().instanceAnchor(AnchorLine::HorizontalCenter).qmlItemNode();
+ if (targetNode.isValid())
+ m_horizontalTarget = targetNode;
+ }
emit topAnchorChanged();
emit bottomAnchorChanged();