From 97db8e04ac2efd924c6de4c0bcdcaf845b090bbc Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 9 Aug 2019 16:15:57 +0200 Subject: Port away from QMutexLocker in public headers We can't use qt_scoped_lock/qt_unique_lock here, so port to std::unique_lock and std::lock_guard for now. This is in preparation of deprecating QMutexLocker in favor of std::unique_lock and std::scoped_lock. In QFutureInterface, change the return type of mutex() from QMutex* to QMutex&, so we don't need to deref when passing to std::lock_guard. We need to keep the old method around for BC reasons, so the new one needs an artificial function argument for disambiguation. This will vanish come Qt 6. Change-Id: I1a0f0205952a249512ec2dbd3f0f48dd209b1636 Reviewed-by: Thiago Macieira --- src/corelib/global/qglobalstatic.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 7a7d65ed76..e56fe1dbcb 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -98,6 +98,7 @@ enum GuardValues { QT_END_NAMESPACE #include +#include QT_BEGIN_NAMESPACE #define Q_GLOBAL_STATIC_INTERNAL(ARGS) \ @@ -107,7 +108,7 @@ QT_BEGIN_NAMESPACE static QBasicMutex mutex; \ int x = guard.loadAcquire(); \ if (Q_UNLIKELY(x >= QtGlobalStatic::Uninitialized)) { \ - QMutexLocker locker(&mutex); \ + const std::lock_guard locker(mutex); \ if (guard.loadRelaxed() == QtGlobalStatic::Uninitialized) { \ d = new Type ARGS; \ static struct Cleanup { \ -- cgit v1.2.3