aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2024-02-12 17:39:10 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2024-03-14 11:41:59 +0100
commit8896d380ae253a259192ef4e9225c6dfe7c271c1 (patch)
tree409a93466b2383d06e89186ba04ffb9f59c7689c /src/qml/qml
parent9d3126b2eec6e9503cc4dc876ee9885de619e375 (diff)
Make loadFromModule compatible with QQmlParserStatus
...as well as the private finalizer hook. Given that QQmlComponent::loadFromModule creates the object through the QML engine, we should support the lifecycle methods, even if we sidestep the usual creation process through the QQmlObjectCreator. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-122076 Change-Id: I2dfe5dd607414df123519d9fccd4178cc5e4cde7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 1b6bac5d0e..73e523fec6 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1092,8 +1092,15 @@ QObject *QQmlComponentPrivate::beginCreate(QQmlRefPointer<QQmlContextData> conte
state.appendCreatorErrors();
enginePriv->dereferenceScarceResources();
} else {
+ // TODO: extract into function
rv = loadedType.createWithQQmlData();
QQmlPropertyCache::ConstPtr propertyCache = QQmlData::ensurePropertyCache(rv);
+ QQmlParserStatus *parserStatus = nullptr;
+ const int parserStatusCast = loadedType.parserStatusCast();
+ if (parserStatusCast != -1) {
+ parserStatus = reinterpret_cast<QQmlParserStatus*>(reinterpret_cast<char *>(rv) + parserStatusCast);
+ parserStatus->classBegin();
+ }
for (int i = 0, propertyCount = propertyCache->propertyCount(); i < propertyCount; ++i) {
if (const QQmlPropertyData *propertyData = propertyCache->property(i); propertyData->isRequired()) {
state.ensureRequiredPropertyStorage();
@@ -1102,6 +1109,12 @@ QObject *QQmlComponentPrivate::beginCreate(QQmlRefPointer<QQmlContextData> conte
state.addPendingRequiredProperty(rv, propertyData, info);
}
}
+ if (parserStatus)
+ parserStatus->componentComplete();
+ if (const int finalizerCast = loadedType.finalizerCast(); finalizerCast != -1) {
+ auto* hook = reinterpret_cast<QQmlFinalizerHook *>(reinterpret_cast<char *>(rv) + finalizerCast);
+ hook->componentFinalized();
+ }
}
if (rv) {