From 52fcd0b6d7184bafef6b1b550c3cd887a7ab7c27 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Mon, 1 Feb 2021 18:41:42 +0100 Subject: [PATCH] Add method to conditionally remove binding to QObjectCompatProperty Setters of QObjectCompatProperty need to remove the binding, but only if it is not in the wrapper. This patch adds this method to the public interface. Change-Id: Ibc96418fe15b0aeeb2059411ea910ba1f733c255 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qproperty_p.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index f4fee1befba..1e6dab4c643 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -504,6 +504,16 @@ public: } } + void removeBindingUnlessInWrapper() + { + QBindingStorage *storage = qGetBindingStorage(owner()); + auto *bd = storage->bindingData(this); + // make sure we don't remove the binding if called from the bindingWrapper + const bool inWrapper = inBindingWrapper(storage); + if (bd && !inWrapper) + bd->removeBinding(); + } + QPropertyBinding binding() const { auto *bd = qGetBindingStorage(owner())->bindingData(this);