aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlengine_p.h
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-07-03 17:23:04 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-09-21 15:20:17 +0200
commit5a1f13e1fcdfeb2611e4dad756da83303c1f6a2e (patch)
tree6c28c0fcd74aa1717808af364379bb2614035a32 /src/qml/qml/qqmlengine_p.h
parent47313e5181e87fd904e6de41c75dfc844ec3f278 (diff)
Handle QProperty inside bindings
If we have a binding containing QProperties, and the binding target is an old style binding, still we have to trigger an update if any of the captured properties changes. We cannot reuse the QQmlJavaScriptExpressionGuards as those depend on Qt's signals, and a QProperty is not associated with a change signal in the general case. Therefore, we introduce a new list of QPropertyChangeHandler, which when triggered cause a reevaluation of the binding. As an optimization, we skip the whole capturing process for QQmlPropertyBinding, as that one already takes care of updating itself. Reverts 845bbb99a41a3e4f05c2b3d05d6db748c825dca0 (because skipping the capture is only possible when _both_ the bindee and the property in the binding are QProperty based.) Change-Id: Iafed2a41dcd708bcc33912ce810d803949379c63 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.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index f8b8b187a5..1f513ef8cc 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -81,6 +81,8 @@
#include <private/qjsengine_p.h>
#include <private/qqmldirparser_p.h>
+#include <qproperty.h>
+
QT_BEGIN_NAMESPACE
class QQmlContext;
@@ -125,6 +127,18 @@ public:
QQmlJavaScriptExpressionGuard *next;
};
+struct QPropertyChangeTrigger {
+ QQmlJavaScriptExpression * m_expression;
+ void operator()();
+};
+
+struct TriggerList : QPropertyChangeHandler<QPropertyChangeTrigger> {
+ TriggerList(QPropertyChangeTrigger trigger) : QPropertyChangeHandler<QPropertyChangeTrigger>(trigger) {};
+ TriggerList *next = nullptr;
+ QObject *target = nullptr;
+ int propertyIndex = 0;
+};
+
class Q_QML_PRIVATE_EXPORT QQmlEnginePrivate : public QJSEnginePrivate
{
Q_DECLARE_PUBLIC(QQmlEngine)
@@ -140,6 +154,7 @@ public:
QQmlPropertyCapture *propertyCapture;
QRecyclePool<QQmlJavaScriptExpressionGuard> jsExpressionGuardPool;
+ QRecyclePool<TriggerList> qPropertyTriggerPool;
QQmlContext *rootContext;