From 3acde1af1153d630fbbd4a5ad6513736cfe3af99 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 12 Sep 2024 16:38:12 +0200 Subject: [PATCH] QtPrivate::CurrentCompatPropertyThief: port to QScopedValueRollback It's what the class is doing, with a bit of convenience on top, to get from QBindingStatus* to its currentCompatProperty, so implement it like that. Simplifies the implementation and fixes a -Wshadow in the constructor. Amends c4bfd32cca547504ebccfad3da4e73a2b712baea. Pick-to: 6.7 6.5 6.2 Task-number: QTBUG-126219 Change-Id: I4ce32e6ae6e6794b578d967c3e22854091470a14 Reviewed-by: Ulf Hermann (cherry picked from commit 97cd2e384960a4e9951bd906ba4c52e07c0ea4c5) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qproperty_p.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 7d9bfa3d77e..b2059229d20 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -242,21 +242,12 @@ struct CompatPropertySafePoint struct CurrentCompatPropertyThief { Q_DISABLE_COPY_MOVE(CurrentCompatPropertyThief) + QScopedValueRollback m_guard; public: CurrentCompatPropertyThief(QBindingStatus *status) - : status(&status->currentCompatProperty) - , stolen(std::exchange(status->currentCompatProperty, nullptr)) + : m_guard(status->currentCompatProperty, nullptr) { } - - ~CurrentCompatPropertyThief() - { - *status = stolen; - } - -private: - CompatPropertySafePoint **status = nullptr; - CompatPropertySafePoint *stolen = nullptr; }; }