From bc080a909b8bb67c1fb23afca69682ba86cdf526 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 4 Dec 2024 13:58:39 -0800 Subject: [PATCH] QMutex: remove QMutexPrivate from the public-ish API Pass the pointer as a void* to avoid having "QMutexPrivate" in the ABI that user content calls. To have such a private type in ABI used by inlines in user code required an ELFIGNORE in qmutex_p.h. This change removes that need for Qt 7. We can't add an #ifdef for the comment block because "ignore-next" would then apply to the #endif line. Therefore, a ### Qt7 comment will have to suffice. It's harmless if we forget to do it. Change-Id: I83e6ddaf775e71eacb42fffd5cd6b87527b9c08b Reviewed-by: Allan Sandfeld Jensen --- src/corelib/compat/removed_api.cpp | 9 +++++++++ src/corelib/thread/qmutex.cpp | 3 ++- src/corelib/thread/qmutex.h | 3 +++ src/corelib/thread/qmutex_p.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index fdf2fe51347..bdb811a1d0d 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -1274,6 +1274,15 @@ QByteArray QMetaEnum::valueToKeys(int value) const } +#include "qmutex.h" + +#if QT_CONFIG(thread) +void QBasicMutex::destroyInternal(QMutexPrivate *d) +{ + return destroyInternal(static_cast(d)); +} +#endif + #include "qstring.h" QString QString::arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index ec6c711a4f2..25cd9bcd9ec 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -101,8 +101,9 @@ static inline QMutexPrivate *dummyFutexValue() \warning Destroying a locked mutex may result in undefined behavior. */ -void QBasicMutex::destroyInternal(QMutexPrivate *d) +void QBasicMutex::destroyInternal(void *ptr) { + auto d = static_cast(ptr); if (!d) return; if (!futexAvailable()) { diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 743b86939eb..1c01bdc763a 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -88,7 +88,10 @@ private: bool lockInternal(int timeout) QT_MUTEX_LOCK_NOEXCEPT; #endif void unlockInternal() noexcept; +#if QT_CORE_REMOVED_SINCE(6, 9) void destroyInternal(QMutexPrivate *d); +#endif + void destroyInternal(void *d); QBasicAtomicPointer d_ptr; static inline QMutexPrivate *dummyLocked() { diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h index aabb66fa550..69963cae86f 100644 --- a/src/corelib/thread/qmutex_p.h +++ b/src/corelib/thread/qmutex_p.h @@ -35,6 +35,7 @@ struct timespec; QT_BEGIN_NAMESPACE +// ### Qt7 remove this comment block // We manipulate the pointer to this class in inline, atomic code, // so syncqt mustn't mark them as private, so ELFVERSION:ignore-next class QMutexPrivate