aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/qml/qqmlengine.cpp15
-rw-r--r--src/qml/qml/qqmlengine.h2
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp14
3 files changed, 22 insertions, 9 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 3f871d5c6a..b5b36cccb9 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -1327,6 +1327,21 @@ void QQmlEngine::setOutputWarningsToStandardError(bool enabled)
}
/*!
+ \internal
+
+ Capture the given property as part of a binding.
+ */
+void QQmlEngine::captureProperty(QObject *object, const QMetaProperty &property) const
+{
+ Q_D(const QQmlEngine);
+ if (d->propertyCapture) {
+ d->propertyCapture->captureProperty(
+ object, property.propertyIndex(),
+ QMetaObjectPrivate::signalIndex(property.notifySignal()));
+ }
+}
+
+/*!
\qmlproperty string Qt::uiLanguage
\since 5.15
diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h
index 0f9e6da63f..37ca25779f 100644
--- a/src/qml/qml/qqmlengine.h
+++ b/src/qml/qml/qqmlengine.h
@@ -158,6 +158,8 @@ public:
template<typename T>
T singletonInstance(int qmlTypeId);
+ void captureProperty(QObject *object, const QMetaProperty &property) const;
+
public Q_SLOTS:
void retranslate();
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 3b6c448e49..e77738d985 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -1370,15 +1370,11 @@ ReturnedValue QtObject::method_get_uiLanguage(const FunctionObject *b, const Val
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(scope.engine);
if (ep && ep->propertyCapture) {
- static int propertyIndex = -1;
- static int notifySignalIndex = -1;
- if (propertyIndex < 0) {
- QMetaProperty metaProperty =
- QQmlEngine::staticMetaObject.property(QQmlEngine::staticMetaObject.indexOfProperty("uiLanguage"));
- propertyIndex = metaProperty.propertyIndex();
- notifySignalIndex = metaProperty.notifySignalIndex();
- }
- ep->propertyCapture->captureProperty(QQmlEnginePrivate::get(ep), propertyIndex, notifySignalIndex);
+ static const QMetaProperty metaProperty
+ = QQmlEngine::staticMetaObject.property(
+ QQmlEngine::staticMetaObject.indexOfProperty("uiLanguage"));
+ QQmlEngine *e = QQmlEnginePrivate::get(ep);
+ e->captureProperty(e, metaProperty);
}
return Encode(scope.engine->newString(QJSEnginePrivate::get(jsEngine)->uiLanguage));