SingleApplication: Use new QSharedMemory constructor with Qt 6.6 and higher
This commit is contained in:
@@ -39,6 +39,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
|
#include <QNativeIpcKey>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
@@ -71,13 +72,21 @@ SingleApplication::SingleApplication(int &argc, char *argv[], const bool allowSe
|
|||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
#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.
|
// 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_);
|
d->memory_ = new QSharedMemory(d->blockServerName_);
|
||||||
|
#endif
|
||||||
d->memory_->attach();
|
d->memory_->attach();
|
||||||
delete d->memory_;
|
delete d->memory_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Guarantee thread safe behaviour with a shared memory block.
|
// 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_);
|
d->memory_ = new QSharedMemory(d->blockServerName_);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Create a shared memory block
|
// Create a shared memory block
|
||||||
if (d->memory_->create(sizeof(InstancesInfo))) {
|
if (d->memory_->create(sizeof(InstancesInfo))) {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
|
#include <QNativeIpcKey>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
@@ -71,13 +72,21 @@ SingleCoreApplication::SingleCoreApplication(int &argc, char *argv[], const bool
|
|||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
#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.
|
// 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_);
|
d->memory_ = new QSharedMemory(d->blockServerName_);
|
||||||
|
#endif
|
||||||
d->memory_->attach();
|
d->memory_->attach();
|
||||||
delete d->memory_;
|
delete d->memory_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Guarantee thread safe behaviour with a shared memory block.
|
// 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_);
|
d->memory_ = new QSharedMemory(d->blockServerName_);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Create a shared memory block
|
// Create a shared memory block
|
||||||
if (d->memory_->create(sizeof(InstancesInfo))) {
|
if (d->memory_->create(sizeof(InstancesInfo))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user