From 6da1f72311b844b2232da3067ad6e1e24614e67c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 14 May 2024 06:51:05 +0200 Subject: [PATCH] QThreadStorage: replace QScoped- with std::unique_ptr This only affects the !QT_CONFIG(thread) case and requires the rewrite of the old-style static cleanup() deleter protocol into the modern operator()() one. As a drive-by, mark the deleter noexcept, like destructors are supposed to be. Pick-to: 6.9 6.8 Task-number: QTBUG-132213 Change-Id: I8839865880647d76b77eb9a3f2858067db86234e Reviewed-by: Thiago Macieira --- src/corelib/thread/qthreadstorage.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/corelib/thread/qthreadstorage.h b/src/corelib/thread/qthreadstorage.h index d81c8d85d89..77d15485b6f 100644 --- a/src/corelib/thread/qthreadstorage.h +++ b/src/corelib/thread/qthreadstorage.h @@ -115,18 +115,17 @@ public: #else // !QT_CONFIG(thread) -#include - +#include #include template -inline bool qThreadStorage_hasLocalData(const QScopedPointer &data) +inline bool qThreadStorage_hasLocalData(const std::unique_ptr &data) { return !!data; } template -inline bool qThreadStorage_hasLocalData(const QScopedPointer &data) +inline bool qThreadStorage_hasLocalData(const std::unique_ptr &data) { return !!data ? *data != nullptr : false; } @@ -150,14 +149,14 @@ class QThreadStorage private: struct ScopedPointerThreadStorageDeleter { - static inline void cleanup(T *t) + void operator()(T *t) const noexcept { if (t == nullptr) return; qThreadStorage_deleteLocalData(t); } }; - QScopedPointer data; + std::unique_ptr data; public: QThreadStorage() = default;