From 016581e1ca8d748e99dea2edfd92ee64b8251ae7 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 20 Feb 2023 17:06:46 +0800 Subject: [PATCH] Add missing deprecation guards The deprecated implementation of QSharedMemory and QSystemSemaphore are not correctly guarded by the deprecation macros, and thus it's causing compilation errors when we disable deprecated code. As a drive-by, change the deprecate version from 6.9 to 6.10 as requested. Change-Id: Icfed181c27248b9e1381101a64523419097dd1da Reviewed-by: Thiago Macieira --- src/corelib/global/qtdeprecationmarkers.h | 14 ++++++++++++++ src/corelib/ipc/qsharedmemory.cpp | 7 +++++++ src/corelib/ipc/qsharedmemory.h | 9 ++++----- src/corelib/ipc/qsystemsemaphore.cpp | 4 ++++ src/corelib/ipc/qsystemsemaphore.h | 9 ++++----- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/corelib/global/qtdeprecationmarkers.h b/src/corelib/global/qtdeprecationmarkers.h index e87c860400..d283954167 100644 --- a/src/corelib/global/qtdeprecationmarkers.h +++ b/src/corelib/global/qtdeprecationmarkers.h @@ -201,6 +201,14 @@ QT_BEGIN_NAMESPACE # define QT_DEPRECATED_VERSION_6_9 #endif +#if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 10, 0) +# define QT_DEPRECATED_VERSION_X_6_10(text) QT_DEPRECATED_X(text) +# define QT_DEPRECATED_VERSION_6_10 QT_DEPRECATED +#else +# define QT_DEPRECATED_VERSION_X_6_10(text) +# define QT_DEPRECATED_VERSION_6_10 +#endif + #define QT_DEPRECATED_VERSION_X_5(minor, text) QT_DEPRECATED_VERSION_X_5_##minor(text) #define QT_DEPRECATED_VERSION_X(major, minor, text) QT_DEPRECATED_VERSION_X_##major##_##minor(text) @@ -297,6 +305,12 @@ QT_BEGIN_NAMESPACE # define QT_IF_DEPRECATED_SINCE_6_9(whenTrue, whenFalse) whenTrue #endif +#if QT_DEPRECATED_SINCE(6, 10) +# define QT_IF_DEPRECATED_SINCE_6_10(whenTrue, whenFalse) whenFalse +#else +# define QT_IF_DEPRECATED_SINCE_6_10(whenTrue, whenFalse) whenTrue +#endif + #ifdef __cplusplus // A tag to help mark stuff deprecated (cf. QStringViewLiteral) namespace QtPrivate { diff --git a/src/corelib/ipc/qsharedmemory.cpp b/src/corelib/ipc/qsharedmemory.cpp index ea0ff4f1b3..9e33b1d995 100644 --- a/src/corelib/ipc/qsharedmemory.cpp +++ b/src/corelib/ipc/qsharedmemory.cpp @@ -132,6 +132,7 @@ QSharedMemory::QSharedMemory(const QNativeIpcKey &key, QObject *parent) setNativeKey(key); } +#if QT_DEPRECATED_SINCE(6, 10) /*! \deprecated @@ -148,6 +149,7 @@ QSharedMemory::QSharedMemory(const QString &key, QObject *parent) { d_func()->legacyKey = key; } +#endif /*! The destructor clears the key, which forces the shared memory object @@ -166,7 +168,9 @@ QSharedMemory::~QSharedMemory() d->cleanHandle(); } +#if QT_DEPRECATED_SINCE(6, 10) /*! + \deprecated \overload Sets the legacy \a key for this shared memory object. If \a key is the same @@ -192,6 +196,7 @@ void QSharedMemory::setKey(const QString &key) setNativeKey(legacyNativeKey(key)); d->legacyKey = key; } +#endif /*! \since 4.8 @@ -300,6 +305,7 @@ bool QSharedMemoryPrivate::initKey(SemaphoreAccessMode mode) return true; } +#if QT_DEPRECATED_SINCE(6, 10) /*! \deprecated Returns the legacy key assigned with setKey() to this shared memory, or a null key @@ -317,6 +323,7 @@ QString QSharedMemory::key() const Q_D(const QSharedMemory); return d->legacyKey; } +#endif /*! \since 4.8 diff --git a/src/corelib/ipc/qsharedmemory.h b/src/corelib/ipc/qsharedmemory.h index 2944366095..f8218cb0fe 100644 --- a/src/corelib/ipc/qsharedmemory.h +++ b/src/corelib/ipc/qsharedmemory.h @@ -50,12 +50,12 @@ public: QSharedMemory(const QNativeIpcKey &key, QObject *parent = nullptr); ~QSharedMemory(); -#if QT_DEPRECATED_SINCE(6, 9) - QT_DEPRECATED_VERSION_X_6_9("Please refer to 'Native IPC Key' documentation") +#if QT_DEPRECATED_SINCE(6, 10) + QT_DEPRECATED_VERSION_X_6_10("Please refer to 'Native IPC Key' documentation") QSharedMemory(const QString &key, QObject *parent = nullptr); - QT_DEPRECATED_VERSION_X_6_9("Please refer to 'Native IPC Key' documentation") + QT_DEPRECATED_VERSION_X_6_10("Please refer to 'Native IPC Key' documentation") void setKey(const QString &key); - QT_DEPRECATED_VERSION_X_6_9("Please refer to 'Native IPC Key' documentation") + QT_DEPRECATED_VERSION_X_6_10("Please refer to 'Native IPC Key' documentation") QString key() const; #endif @@ -102,4 +102,3 @@ private: QT_END_NAMESPACE #endif // QSHAREDMEMORY_H - diff --git a/src/corelib/ipc/qsystemsemaphore.cpp b/src/corelib/ipc/qsystemsemaphore.cpp index c41ae6dbc2..0f59b378a3 100644 --- a/src/corelib/ipc/qsystemsemaphore.cpp +++ b/src/corelib/ipc/qsystemsemaphore.cpp @@ -68,6 +68,7 @@ inline void QSystemSemaphorePrivate::destructBackend() \sa {Inter-Process Communication}, QSharedMemory, QSemaphore */ +#if QT_DEPRECATED_SINCE(6, 10) /*! \deprecated @@ -85,6 +86,7 @@ QSystemSemaphore::QSystemSemaphore(const QString &key, int initialValue, AccessM { d->legacyKey = key; } +#endif /*! Requests a system semaphore for the specified \a key. The parameters @@ -227,6 +229,7 @@ QNativeIpcKey QSystemSemaphore::nativeIpcKey() const return d->nativeKey; } +#if QT_DEPRECATED_SINCE(6, 10) /*! \deprecated This function works the same as the constructor. It reconstructs @@ -255,6 +258,7 @@ QString QSystemSemaphore::key() const { return d->legacyKey; } +#endif /*! Acquires one of the resources guarded by this semaphore, if there is diff --git a/src/corelib/ipc/qsystemsemaphore.h b/src/corelib/ipc/qsystemsemaphore.h index 2eec661ab3..bd0057e6b7 100644 --- a/src/corelib/ipc/qsystemsemaphore.h +++ b/src/corelib/ipc/qsystemsemaphore.h @@ -47,12 +47,12 @@ public: { setNativeKey({ key, type }, initialValue, mode); } QNativeIpcKey nativeIpcKey() const; -#if QT_DEPRECATED_SINCE(6, 9) - QT_DEPRECATED_VERSION_X_6_9("Please refer to 'Native IPC Key' documentation") +#if QT_DEPRECATED_SINCE(6, 10) + QT_DEPRECATED_VERSION_X_6_10("Please refer to 'Native IPC Key' documentation") QSystemSemaphore(const QString &key, int initialValue = 0, AccessMode mode = Open); - QT_DEPRECATED_VERSION_X_6_9("Please refer to 'Native IPC Key' documentation") + QT_DEPRECATED_VERSION_X_6_10("Please refer to 'Native IPC Key' documentation") void setKey(const QString &key, int initialValue = 0, AccessMode mode = Open); - QT_DEPRECATED_VERSION_X_6_9("Please refer to 'Native IPC Key' documentation") + QT_DEPRECATED_VERSION_X_6_10("Please refer to 'Native IPC Key' documentation") QString key() const; #endif @@ -78,4 +78,3 @@ private: QT_END_NAMESPACE #endif // QSYSTEMSEMAPHORE_H -