diff options
Diffstat (limited to 'src/corelib/ipc/qsharedmemory.cpp')
-rw-r--r-- | src/corelib/ipc/qsharedmemory.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/corelib/ipc/qsharedmemory.cpp b/src/corelib/ipc/qsharedmemory.cpp index 139c1440e3..02761c0263 100644 --- a/src/corelib/ipc/qsharedmemory.cpp +++ b/src/corelib/ipc/qsharedmemory.cpp @@ -125,24 +125,17 @@ QSharedMemory::QSharedMemory(const QNativeIpcKey &key, QObject *parent) setNativeKey(key); } -#if QT_DEPRECATED_SINCE(6, 10) /*! - \deprecated - Constructs a shared memory object with the given \a parent and with the legacy key set to \a key. Because its key is set, its create() and attach() functions can be called. - Legacy keys are deprecated. See \l{Native IPC Keys} for more information. - \sa setKey(), create(), attach() */ QSharedMemory::QSharedMemory(const QString &key, QObject *parent) : QSharedMemory(legacyNativeKey(key), parent) { - d_func()->legacyKey = key; } -#endif /*! The destructor clears the key, which forces the shared memory object @@ -161,9 +154,7 @@ 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 @@ -185,11 +176,8 @@ QSharedMemory::~QSharedMemory() */ void QSharedMemory::setKey(const QString &key) { - Q_D(QSharedMemory); setNativeKey(legacyNativeKey(key)); - d->legacyKey = key; } -#endif /*! \since 4.8 @@ -245,7 +233,6 @@ void QSharedMemory::setNativeKey(const QNativeIpcKey &key) if (isAttached()) detach(); d->cleanHandle(); - d->legacyKey = QString(); if (key.type() == d->nativeKey.type()) { // we can reuse the backend d->nativeKey = key; @@ -262,7 +249,11 @@ bool QSharedMemoryPrivate::initKey(SemaphoreAccessMode mode) if (!cleanHandle()) return false; #if QT_CONFIG(systemsemaphore) - systemSemaphore.setNativeKey(semaphoreNativeKey(), 1, mode); + const QString legacyKey = QNativeIpcKeyPrivate::legacyKey(nativeKey); + const QNativeIpcKey semKey = legacyKey.isEmpty() + ? semaphoreNativeKey() + : QSystemSemaphore::legacyNativeKey(legacyKey, nativeKey.type()); + systemSemaphore.setNativeKey(semKey, 1, mode); if (systemSemaphore.error() != QSystemSemaphore::NoError) { QString function = "QSharedMemoryPrivate::initKey"_L1; errorString = QSharedMemory::tr("%1: unable to set key on lock (%2)") @@ -298,9 +289,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 if no key has been assigned, or if the segment is using a nativeKey(). The key is the identifier used by Qt applications to identify the shared memory @@ -314,9 +303,8 @@ bool QSharedMemoryPrivate::initKey(SemaphoreAccessMode mode) QString QSharedMemory::key() const { Q_D(const QSharedMemory); - return d->legacyKey; + return QNativeIpcKeyPrivate::legacyKey(d->nativeKey); } -#endif /*! \since 4.8 @@ -686,12 +674,12 @@ bool QSharedMemory::isKeyTypeSupported(QNativeIpcKey::Type type) QNativeIpcKey QSharedMemory::platformSafeKey(const QString &key, QNativeIpcKey::Type type) { - return { QtIpcCommon::platformSafeKey(key, IpcType::SharedMemory, type), type }; + return QtIpcCommon::platformSafeKey(key, IpcType::SharedMemory, type); } QNativeIpcKey QSharedMemory::legacyNativeKey(const QString &key, QNativeIpcKey::Type type) { - return { legacyPlatformSafeKey(key, IpcType::SharedMemory, type), type }; + return QtIpcCommon::legacyPlatformSafeKey(key, IpcType::SharedMemory, type); } #endif // QT_CONFIG(sharedmemory) |