diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-06-25 16:16:58 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-08-09 14:53:44 +0000 |
commit | 3cf2df4a7e8a53a63068613311c4799e55c971b9 (patch) | |
tree | e06c00cc157af252a179d9af83ff78bbb832b1e0 /src/qml | |
parent | 00b580427071acb9341bc49fe37e289201cbf02c (diff) |
Skip superfluous property capture attempt
If a QQmlProperyBinding tries to capture a QProperty, there is nothing
to do as the dependency tracking happens in C++ anyway. Thus we can
avoid calling captureProperty.
Pick-to: 6.2
Change-Id: I96b2876d4b2ba10b00af8342be9beae660a95ef3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlbinding_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlboundsignal_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlexpression_p.h | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression_p.h | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertybinding_p.h | 2 |
7 files changed, 11 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 49a43860df..1d5d3dedf7 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -289,7 +289,8 @@ ReturnedValue QObjectWrapper::getProperty(ExecutionEngine *engine, QObject *obje QQmlEnginePrivate *ep = engine->qmlEngine() ? QQmlEnginePrivate::get(engine->qmlEngine()) : nullptr; if (ep && ep->propertyCapture && !property->isConstant()) - ep->propertyCapture->captureProperty(object, property->coreIndex(), property->notifyIndex()); + if (!property->isBindable() || ep->propertyCapture->expression->mustCaptureBindableProperty()) + ep->propertyCapture->captureProperty(object, property->coreIndex(), property->notifyIndex()); if (property->isVarProperty()) { QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index 4e824fff03..6ba492f0e4 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -97,6 +97,8 @@ public: ~QQmlBinding() override; + bool mustCaptureBindableProperty() const final {return true;} + void setTarget(const QQmlProperty &); bool setTarget(QObject *, const QQmlPropertyData &, const QQmlPropertyData *valueType); bool setTarget(QObject *, int coreIndex, bool coreIsAlias, int valueTypeIndex); diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h index 0a3229b731..89635dec69 100644 --- a/src/qml/qml/qqmlboundsignal_p.h +++ b/src/qml/qml/qqmlboundsignal_p.h @@ -80,6 +80,8 @@ public: // evaluation of a bound signal expression doesn't return any value void evaluate(void **a); + bool mustCaptureBindableProperty() const final {return true;} + QString expression() const; const QObject *target() const { return m_target; } diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h index 3df839a6a2..26c0cddb9e 100644 --- a/src/qml/qml/qqmlexpression_p.h +++ b/src/qml/qml/qqmlexpression_p.h @@ -76,6 +76,7 @@ public: QVariant value(bool *isUndefined = nullptr); QV4::ReturnedValue v4value(bool *isUndefined = nullptr); + bool mustCaptureBindableProperty() const final {return true;} static inline QQmlExpressionPrivate *get(QQmlExpression *expr); static inline QQmlExpression *get(QQmlExpressionPrivate *expr); diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index c4c37a32be..f25fd0795c 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -394,7 +394,7 @@ void QQmlPropertyCapture::captureBindableProperty( { // if the property is a QPropery, and we're binding to a QProperty // the automatic capturing process already takes care of everything - if (typeid(QQmlPropertyBindingJS) == typeid(*expression)) + if (!expression->mustCaptureBindableProperty()) return; for (auto trigger = expression->qpropertyChangeTriggers; trigger; trigger = trigger->next) { diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 7a741afb75..dc2289a357 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -158,6 +158,7 @@ public: void clearError(); void clearActiveGuards(); QQmlDelayedError *delayedError(); + virtual bool mustCaptureBindableProperty() const {return true;} static QV4::ReturnedValue evalFunction( const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope, const QString &code, diff --git a/src/qml/qml/qqmlpropertybinding_p.h b/src/qml/qml/qqmlpropertybinding_p.h index d4b339b6e2..c2af93869a 100644 --- a/src/qml/qml/qqmlpropertybinding_p.h +++ b/src/qml/qml/qqmlpropertybinding_p.h @@ -70,6 +70,8 @@ class QQmlPropertyBinding; class Q_QML_PRIVATE_EXPORT QQmlPropertyBindingJS : public QQmlJavaScriptExpression { + bool mustCaptureBindableProperty() const final {return false;} + friend class QQmlPropertyBinding; void expressionChanged() override; QQmlPropertyBinding *asBinding() |