From 25f396218d2eb86607a88b4f76edee7f78948816 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 11 Jun 2025 10:10:43 -0700 Subject: [PATCH] QBasicMutex: bring back fastTryUnlock for MSVC MSVC exports inline functions, so we're not allowed to remove them. This is an unlikely problem, though, since it was only called from other inline functions: if the compiler was inlining content into user code (as it should), then it would likely have inlined this one too; if instead the inliner was disabled, then it wouldn't have inlined the caller either. Amends commit 1957597aa6bc6ebd8bd1f903389800897411ac5d. Seen in API review. Pick-to: 6.10 Task-number: QTBUG-137478 Change-Id: Idd01170c3396c5b6fefefffd748f3335fc42fd79 Reviewed-by: Marc Mutz --- src/corelib/compat/removed_api.cpp | 2 ++ src/corelib/thread/qmutex.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index 316c3518501..8260d50fd3a 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -1461,6 +1461,8 @@ QNoDebug QMessageLogger::noDebug() const noexcept return QNoDebug(); } +#include "qmutex.h" // removed, previously-inline API + #include "qstring.h" // inlined API // #include "qotherheader.h" diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 68377f3d699..a45dcee2756 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -88,6 +88,11 @@ private: return false; return d_ptr.testAndSetAcquire(nullptr, dummyLocked()); } +#if QT_CORE_REMOVED_SINCE(6, 10) + inline bool fastTryUnlock() noexcept { + return d_ptr.testAndSetRelease(dummyLocked(), nullptr); + } +#endif void lockInternal() noexcept(FutexAlwaysAvailable); bool lockInternal(QDeadlineTimer timeout) noexcept(FutexAlwaysAvailable);