From c13aa48d4cad8659af2b491e4b3ddbe46b38fcc5 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 30 Aug 2016 12:35:36 +0200 Subject: QML: treat permanent guards more like active guards Esp. when disabling notifications and marking notifiers as "done". Change-Id: I2d1c3bf048b32f68680744250e4250c3c4d76660 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlbinding.cpp | 2 ++ src/qml/qml/qqmljavascriptexpression.cpp | 10 ++++++++-- src/qml/qml/qqmljavascriptexpression_p.h | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 896bc8d51d..90698c3b24 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -252,6 +252,8 @@ protected: } + cancelPermanentGuards(); + ep->dereferenceScarceResources(); } diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index ebc4d49c36..8020bdb2be 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -115,12 +115,17 @@ QQmlJavaScriptExpression::~QQmlJavaScriptExpression() void QQmlJavaScriptExpression::setNotifyOnValueChanged(bool v) { activeGuards.setFlagValue(v); - if (!v) clearActiveGuards(); + permanentGuards.setFlagValue(v); + if (!v) { + clearActiveGuards(); + clearPermanentGuards(); + m_permanentDependenciesRegistered = false; + } } void QQmlJavaScriptExpression::resetNotifyOnValueChanged() { - clearActiveGuards(); + setNotifyOnValueChanged(false); } void QQmlJavaScriptExpression::setContext(QQmlContextData *context) @@ -429,6 +434,7 @@ void QQmlJavaScriptExpression::clearActiveGuards() void QQmlJavaScriptExpression::clearPermanentGuards() { + m_permanentDependenciesRegistered = false; while (QQmlJavaScriptExpressionGuard *g = permanentGuards.takeFirst()) g->Delete(); } diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index a5c7a80153..5f9cffb56d 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -146,6 +146,14 @@ public: protected: void createQmlBinding(QQmlContextData *ctxt, QObject *scope, const QString &code, const QString &filename, quint16 line); + void cancelPermanentGuards() const + { + if (m_permanentDependenciesRegistered) { + for (QQmlJavaScriptExpressionGuard *it = permanentGuards.first(); it; it = permanentGuards.next(it)) + it->cancelNotify(); + } + } + private: friend class QQmlContextData; friend class QQmlPropertyCapture; -- cgit v1.2.3