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 <thiago.macieira@intel.com>
This commit is contained in:
Yuhang Zhao 2023-02-20 17:06:46 +08:00
parent 3c1bea178c
commit 016581e1ca
5 changed files with 33 additions and 10 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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