From 0adc084dad3f387e32f2dcdef4cb191d7408f61a Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 2 Mar 2023 22:57:33 +0100 Subject: [PATCH] SingleApplication: Use new QSharedMemory constructor with Qt 6.6 and higher --- 3rdparty/singleapplication/singleapplication.cpp | 9 +++++++++ 3rdparty/singleapplication/singlecoreapplication.cpp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/3rdparty/singleapplication/singleapplication.cpp b/3rdparty/singleapplication/singleapplication.cpp index c5e30c8e9..2c15ff377 100644 --- a/3rdparty/singleapplication/singleapplication.cpp +++ b/3rdparty/singleapplication/singleapplication.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -71,13 +72,21 @@ SingleApplication::SingleApplication(int &argc, char *argv[], const bool allowSe #ifdef Q_OS_UNIX // By explicitly attaching it and then deleting it we make sure that the memory is deleted even after the process has crashed on Unix. +#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) + d->memory_ = new QSharedMemory(QNativeIpcKey(d->blockServerName_)); +#else d->memory_ = new QSharedMemory(d->blockServerName_); +#endif d->memory_->attach(); delete d->memory_; #endif // Guarantee thread safe behaviour with a shared memory block. +#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) + d->memory_ = new QSharedMemory(QNativeIpcKey(d->blockServerName_)); +#else d->memory_ = new QSharedMemory(d->blockServerName_); +#endif // Create a shared memory block if (d->memory_->create(sizeof(InstancesInfo))) { diff --git a/3rdparty/singleapplication/singlecoreapplication.cpp b/3rdparty/singleapplication/singlecoreapplication.cpp index 652c958a6..23c6f52fc 100644 --- a/3rdparty/singleapplication/singlecoreapplication.cpp +++ b/3rdparty/singleapplication/singlecoreapplication.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -71,13 +72,21 @@ SingleCoreApplication::SingleCoreApplication(int &argc, char *argv[], const bool #ifdef Q_OS_UNIX // By explicitly attaching it and then deleting it we make sure that the memory is deleted even after the process has crashed on Unix. +#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) + d->memory_ = new QSharedMemory(QNativeIpcKey(d->blockServerName_)); +#else d->memory_ = new QSharedMemory(d->blockServerName_); +#endif d->memory_->attach(); delete d->memory_; #endif // Guarantee thread safe behaviour with a shared memory block. +#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) + d->memory_ = new QSharedMemory(QNativeIpcKey(d->blockServerName_)); +#else d->memory_ = new QSharedMemory(d->blockServerName_); +#endif // Create a shared memory block if (d->memory_->create(sizeof(InstancesInfo))) {