diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-10-20 15:41:04 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-01-25 11:21:42 +0100 |
commit | 9eda73354c6caf0b974febc7bdbee136d59a4e36 (patch) | |
tree | a940d5b2fe8d052a19ee80259fd10457e76ff411 /src/qml/qml/qqmlpropertybinding_p.h | |
parent | 4f961f1f580bca602e1c4e8fffd906edb374d03d (diff) |
QQmlPropertyBinding: improve error reporting
This change ensures that bindings created in QML between new-style
properties contain information about which property caused the loop. To
do this, we store additional information about the property involved to
retrieve its name and position at a later point. We print the warning in
case we detect a binding loop in evaluate, and also set the error
reporting callback correctly, so that the condition can be reported when
the loop is detected in another part of the binding evaluation.
In addition, we do not only set the QPropertyBinding's error member when
JS evaluation results in an error, but also print the warning with
qmlWarning.
Fixes: QTBUG-87733
Change-Id: Idb25237d1f57355ca31189e6bf2a918430b3a810
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlpropertybinding_p.h')
-rw-r--r-- | src/qml/qml/qqmlpropertybinding_p.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlpropertybinding_p.h b/src/qml/qml/qqmlpropertybinding_p.h index 1ea82b26be..4a9d1f4558 100644 --- a/src/qml/qml/qqmlpropertybinding_p.h +++ b/src/qml/qml/qqmlpropertybinding_p.h @@ -74,7 +74,8 @@ public: static QUntypedPropertyBinding create(const QQmlPropertyData *pd, QV4::Function *function, QObject *obj, const QQmlRefPointer<QQmlContextData> &ctxt, - QV4::ExecutionContext *scope); + QV4::ExecutionContext *scope, QObject *target, + QQmlPropertyIndex targetIndex); void expressionChanged() override; @@ -87,11 +88,21 @@ public: } private: - QQmlPropertyBinding(QMetaType metaType); + QQmlPropertyBinding(QMetaType metaType, QObject *target, QQmlPropertyIndex targetIndex); bool evaluate(QMetaType metaType, void *dataPtr); + QString createBindingLoopErrorDescription(QJSEnginePrivate *ep); + struct TargetData { + QObject *target; + QQmlPropertyIndex targetIndex; + }; + + QObject *target(); + QQmlPropertyIndex targetIndex(); + + static void bindingErrorCallback(QPropertyBindingPrivate *); }; template <auto I> |