Commit c85ebaca authored by Thomas Hartmann's avatar Thomas Hartmann

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/3327Reviewed-by: default avatarMarco Bubke <marco.bubke@nokia.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 78e96d74
......@@ -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();
......
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