aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlobjectcreator_p.h
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-09-30 11:55:31 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-10-06 00:25:37 +0000
commita038dadf770ddb2697e8404741235317cf2a6674 (patch)
tree0e36faca0ec8348de7bac62914e199f9c343d7b0 /src/qml/qml/qqmlobjectcreator_p.h
parentb3ff3fd2c41adb082a51897fbc02789c488c9a06 (diff)
QQmlObjectCreator: Correctly remove overwritten bindings
For QProperty bindings, we would not explicitly remove bindings that were added and later overwritten. For "complex" bindings, that would cause some unnecessary binding evaluation during object creation. Worse, in the case of a literal binding overwriting a complex binding, we would acutally end up with the complex binding still being there, because the literal binding would result in an immediate write of the value, whereas the binding was only installed at a later point. We fix this by removing the binding from the list of to-be-installed bindings when it gets overwritten. We also now take the IsPropertyObserver flag into consideration when checking whether existing bindings should be removed: IsPropertyObserver is basically the same as IsSignalHandlerExpression, but for QProperty bindings instead of "old-style" bindings. Fixes: QTBUG-96668 Change-Id: I2ef00d5b62af4f6fcc71960c38e1f0568b3b9c40 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 5ff83606a1c1365b95cd12ef9d45bc4e4eb13ecd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator_p.h')
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index 50489fd55b..4e788e88d4 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -89,6 +89,12 @@ struct RequiredPropertyInfo
class RequiredProperties : public QHash<QQmlPropertyData*, RequiredPropertyInfo> {};
+struct DeferredQPropertyBinding {
+ QObject *target = nullptr;
+ int properyIndex = -1;
+ QUntypedPropertyBinding binding;
+};
+
struct QQmlObjectCreatorSharedState : QQmlRefCount
{
QQmlRefPointer<QQmlContextData> rootContext;
@@ -102,7 +108,7 @@ struct QQmlObjectCreatorSharedState : QQmlRefCount
QQmlVmeProfiler profiler;
QRecursionNode recursionNode;
RequiredProperties requiredProperties;
- QList<std::tuple<QObject *, int, QUntypedPropertyBinding>> allQPropertyBindings;
+ QList<DeferredQPropertyBinding> allQPropertyBindings;
bool hadRequiredProperties;
};