forked from qt-creator/qt-creator
QmlDesigner: Fix anchoring for application window
We don't tested that target anchor object are node instances. Now we search for the parent object recursively. Change-Id: I2e03e714f858a285309b02f5e88c757f0dcfe7e5 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -460,11 +460,15 @@ QPair<PropertyName, ServerNodeInstance> GraphicalNodeInstance::anchor(const Prop
|
||||
QObject *targetObject = nameObjectPair.second;
|
||||
PropertyName targetName = nameObjectPair.first.toUtf8();
|
||||
|
||||
if (targetObject && nodeInstanceServer()->hasInstanceForObject(targetObject)) {
|
||||
return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject));
|
||||
} else {
|
||||
return ObjectNodeInstance::anchor(name);
|
||||
while (targetObject) {
|
||||
if (nodeInstanceServer()->hasInstanceForObject(targetObject))
|
||||
return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject));
|
||||
else
|
||||
targetObject = parentObject(targetObject);
|
||||
}
|
||||
|
||||
return ObjectNodeInstance::anchor(name);
|
||||
|
||||
}
|
||||
|
||||
static void doComponentCompleteRecursive(QQuickItem *item)
|
||||
|
||||
@@ -1172,7 +1172,7 @@ QObject *ObjectNodeInstance::parent() const
|
||||
return object()->parent();
|
||||
}
|
||||
|
||||
QObject *parentObject(QObject *object)
|
||||
QObject *ObjectNodeInstance::parentObject(QObject *object)
|
||||
{
|
||||
QQuickItem *quickItem = qobject_cast<QQuickItem*>(object);
|
||||
if (quickItem && quickItem->parentItem()) {
|
||||
|
||||
@@ -190,6 +190,7 @@ protected:
|
||||
void addToNewProperty(QObject *object, QObject *newParent, const PropertyName &newParentProperty);
|
||||
void deleteObjectsInList(const QQmlProperty &metaProperty);
|
||||
QVariant convertSpecialCharacter(const QVariant& value) const;
|
||||
static QObject *parentObject(QObject *object);
|
||||
|
||||
private:
|
||||
QHash<PropertyName, QVariant> m_resetValueHash;
|
||||
|
||||
Reference in New Issue
Block a user