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 <ulf.hermann@qt.io>
(cherry picked from commit 97cd2e384960a4e9951bd906ba4c52e07c0ea4c5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-09-12 16:38:12 +02:00 committed by Qt Cherry-pick Bot
parent 1939eba8a3
commit 3acde1af11

View File

@ -242,21 +242,12 @@ struct CompatPropertySafePoint
struct CurrentCompatPropertyThief
{
Q_DISABLE_COPY_MOVE(CurrentCompatPropertyThief)
QScopedValueRollback<CompatPropertySafePoint *> 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;
};
}