diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2021-11-10 17:26:28 +0100 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2021-11-12 18:57:43 +0100 |
commit | 91ed4cdae1db4f051ac5dddd8b9197c96cf28ac3 (patch) | |
tree | 409462d6729c19fcff6d7c363b82d0be3cc865e3 /src/qml/qml/qqmlengine_p.h | |
parent | e0db57f9d07f47e1fefdd0c6f507e32308e4041c (diff) |
Make QQmlEngine take care of QQmlContext setup
Teach QQmlEnginePrivate to create QQmlContextData for object creation
purposes. This is necessary for both QQmlObjectCreator and qmltc's
generated code
Since tst_qmltc_manual used to test roughly the same code, replace the
test-local implementation with the new one
Task-number: QTBUG-84368
Change-Id: I58a1d4b259f42170d6dfb3809b7dd894bcbacbe1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlengine_p.h')
-rw-r--r-- | src/qml/qml/qqmlengine_p.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index 2d5d75fafe..978b4d2d24 100644 --- a/src/qml/qml/qqmlengine_p.h +++ b/src/qml/qml/qqmlengine_p.h @@ -280,6 +280,23 @@ public: void executeRuntimeFunction(const QUrl &url, qsizetype functionIndex, QObject *thisObject, int argc = 0, void **args = nullptr, QMetaType *types = nullptr); QV4::ExecutableCompilationUnit *compilationUnitFromUrl(const QUrl &url); + QQmlRefPointer<QQmlContextData> + createInternalContext(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit, + const QQmlRefPointer<QQmlContextData> &parentContext, + int subComponentIndex, bool isComponentRoot); + static void setInternalContext(QObject *This, const QQmlRefPointer<QQmlContextData> &context, + QQmlContextData::QmlObjectKind kind) + { + Q_ASSERT(This); + QQmlData *ddata = QQmlData::get(This, /*create*/ true); + // NB: copied from QQmlObjectCreator::createInstance() + // + // the if-statement logic to determine the kind is: + // if (static_cast<quint32>(index) == 0 || ddata->rootObjectInCreation || isInlineComponent) + // then QQmlContextData::DocumentRoot. here, we pass this through qmltc + context->installContext(ddata, kind); + Q_ASSERT(qmlEngine(This)); + } private: class SingletonInstances : private QHash<QQmlType, QJSValue> |