QmlDesigner: Call all Component complete handlers

We have to ensure to properly call all Component complete handlers.
A single component usually has QQmlComponentAttached objects,
which we have to iterate over.

Therefore emitComponentCompleteSignalForAttachedProperty() is not correct.

Task-number: QDS-269
Change-Id: I4aed5d511f9f6e21f72efb955fc6db21b70e7c42
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2018-10-18 15:45:04 +02:00
committed by Tim Jenssen
parent 673a115703
commit 7bff611ee1
3 changed files with 24 additions and 1 deletions
@@ -195,7 +195,7 @@ void QuickItemNodeInstance::doComponentComplete()
QmlPrivateGate::disableTextCursor(quickItem());
DesignerSupport::emitComponentCompleteSignalForAttachedProperty(quickItem());
QmlPrivateGate::emitComponentComplete(quickItem());
QQmlProperty contentItemProperty(quickItem(), "contentItem", engine());
if (contentItemProperty.isValid())
@@ -85,6 +85,7 @@ public:
void setPropertyBinding(QObject *object, QQmlContext *context, const PropertyName &propertyName, const QString &expression);
void keepBindingFromGettingDeleted(QObject *object, QQmlContext *context, const PropertyName &propertyName);
void emitComponentComplete(QObject *item);
void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInstanceServer);
bool objectWasDeleted(QObject *object);
@@ -44,6 +44,8 @@
#include <private/qquickdesignersupportproperties_p.h>
#include <private/qquickdesignersupportpropertychanges_p.h>
#include <private/qquickdesignersupportstates_p.h>
#include <private/qqmldata_p.h>
#include <private/qqmlcomponentattached_p.h>
namespace QmlDesigner {
@@ -216,6 +218,24 @@ void setPropertyBinding(QObject *object, QQmlContext *context, const PropertyNam
QQuickDesignerSupportProperties::setPropertyBinding(object, context, propertyName, expression);
}
void emitComponentComplete(QObject *item)
{
if (!item)
return;
QQmlData *data = QQmlData::get(item);
if (data && data->context) {
QQmlComponentAttached *componentAttached = data->context->componentAttached;
while (componentAttached) {
if (componentAttached->parent())
if (componentAttached->parent() == item)
emit componentAttached->completed();
componentAttached = componentAttached->next;
}
}
}
void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInstanceServer)
{
if (object) {
@@ -224,6 +244,8 @@ void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInsta
if (item && DesignerSupport::isComponentComplete(item))
return;
if (!nodeInstanceServer->hasInstanceForObject(item))
emitComponentComplete(object);
QList<QObject*> childList = object->children();
if (item) {