From ec002f5a0454502ee763993a3cfa7feb5cd2a6d8 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. Task-number: QTBUG-132213 Change-Id: I8839865880647d76b77eb9a3f2858067db86234e Reviewed-by: Thiago Macieira (cherry picked from commit 6da1f72311b844b2232da3067ad6e1e24614e67c) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 7aadf25ccd70fd739a7b06f6b6bccbdee03847a5) --- 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 @@ class QThreadStorage #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;