From f875ff5180345d9e50d594f3f432d5c73eef30e4 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 6 Mar 2022 14:29:54 +0100 Subject: [PATCH] QMutexLocker: code tidies Rename isLocked in preparation for a future commit. Rename m as well for consistency. Change-Id: I1c8d040bca6825a698ec804ea142d208abacd5cc Reviewed-by: Thiago Macieira --- src/corelib/thread/qmutex.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 19463da6198..fea36571508 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -240,43 +240,45 @@ class [[nodiscard]] QMutexLocker public: inline explicit QMutexLocker(Mutex *mutex) QT_MUTEX_LOCK_NOEXCEPT { - m = mutex; + m_mutex = mutex; if (Q_LIKELY(mutex)) { mutex->lock(); - isLocked = true; + m_isLocked = true; } } - inline ~QMutexLocker() { + + inline ~QMutexLocker() + { unlock(); } inline void unlock() noexcept { - if (!isLocked) + if (!m_isLocked) return; - m->unlock(); - isLocked = false; + m_mutex->unlock(); + m_isLocked = false; } inline void relock() QT_MUTEX_LOCK_NOEXCEPT { - if (isLocked) + if (m_isLocked) return; - if (m) { - m->lock(); - isLocked = true; + if (m_mutex) { + m_mutex->lock(); + m_isLocked = true; } } Mutex *mutex() const { - return m; + return m_mutex; } private: Q_DISABLE_COPY(QMutexLocker) - Mutex *m; - bool isLocked = false; + Mutex *m_mutex; + bool m_isLocked = false; }; #else // !QT_CONFIG(thread) && !Q_CLANG_QDOC