From ac415ebbb6a06b137b1a903f4fc58333d9eac01b Mon Sep 17 00:00:00 2001 From: "andrey.bychkov" Date: Wed, 18 Mar 2026 08:54:06 +0300 Subject: [PATCH] revert can_unlock flag --- libs/main/thread/piprotectedvariable.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/main/thread/piprotectedvariable.h b/libs/main/thread/piprotectedvariable.h index 077d2192..754eb4e3 100644 --- a/libs/main/thread/piprotectedvariable.h +++ b/libs/main/thread/piprotectedvariable.h @@ -49,11 +49,15 @@ public: public: //! \~english Move constructor - transfers ownership of the lock. //! \~russian Конструктор перемещения - передает владение блокировкой. - Pointer(Pointer && other): pv(other.pv) { pv.mutex.lock(); }; + Pointer(Pointer && other): pv(other.pv) { other.can_unlock = false; }; //! \~english Destroys wrapper and releases the mutex. //! \~russian Уничтожает обертку и освобождает мьютекс. - ~Pointer() { pv.mutex.unlock(); } + ~Pointer() { + if (can_unlock) { + pv.mutex.unlock(); + } + } //! \~english Returns pointer access to the protected value. //! \~russian Возвращает указательный доступ к защищенному значению. @@ -68,6 +72,7 @@ public: explicit Pointer(PIProtectedVariable & v): pv(v) { pv.mutex.lock(); } PIProtectedVariable & pv; + bool can_unlock = true; }; //! \~english Replaces the protected value with \a v.