From 797a8f2aaaa8133ea8a54d9e4b91ba531fab3070 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 23 Oct 2020 09:50:53 +0200 Subject: QQmlEngine: Add method to explicitly capture a property Also, use that method to capture the uiLanguage notify signal. Previously the wrong signal was captured. The test still happened to pass because we manually re-evaluated all bindings when the uiLanguage property changed. Add a test which avoid that. Change-Id: I3961b60b365a8705930936f20881421bd4ceffe5 Reviewed-by: Fabian Kosmale --- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/qml/qml/v8/qqmlbuiltinfunctions.cpp') 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)); -- cgit v1.2.3