aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index c147feeb73..1371f1f041 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -1119,6 +1119,11 @@ ReturnedValue QtObject::method_createQmlObject(const FunctionObject *b, const Va
QQmlEngine *engine = scope.engine->qmlEngine();
QQmlContextData *context = scope.engine->callingQmlContext();
+ if (!context) {
+ QQmlEngine *qmlEngine = scope.engine->qmlEngine();
+ if (qmlEngine)
+ context = QQmlContextData::get(QQmlEnginePrivate::get(qmlEngine)->rootContext);
+ }
Q_ASSERT(context);
QQmlContext *effectiveContext = nullptr;
if (context->isPragmaLibraryContext)
@@ -1246,6 +1251,11 @@ ReturnedValue QtObject::method_createComponent(const FunctionObject *b, const Va
QQmlEngine *engine = scope.engine->qmlEngine();
QQmlContextData *context = scope.engine->callingQmlContext();
+ if (!context) {
+ QQmlEngine *qmlEngine = scope.engine->qmlEngine();
+ if (qmlEngine)
+ context = QQmlContextData::get(QQmlEnginePrivate::get(qmlEngine)->rootContext);
+ }
Q_ASSERT(context);
QQmlContextData *effectiveContext = context;
if (context->isPragmaLibraryContext)