Implement class for handling filesystem paths

PR #15915.
This commit is contained in:
Vladimir Golovnev 2022-02-08 06:03:48 +03:00 committed by GitHub
parent facfa26eed
commit dd1bd8ad10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
131 changed files with 2252 additions and 1868 deletions

View file

@ -37,18 +37,19 @@
#include <QSharedMemory>
#endif
#include "base/path.h"
#include "qtlocalpeer/qtlocalpeer.h"
ApplicationInstanceManager::ApplicationInstanceManager(const QString &instancePath, QObject *parent)
ApplicationInstanceManager::ApplicationInstanceManager(const Path &instancePath, QObject *parent)
: QObject {parent}
, m_peer {new QtLocalPeer {instancePath, this}}
, m_peer {new QtLocalPeer(instancePath.data(), this)}
, m_isFirstInstance {!m_peer->isClient()}
{
connect(m_peer, &QtLocalPeer::messageReceived, this, &ApplicationInstanceManager::messageReceived);
#ifdef Q_OS_WIN
const QString sharedMemoryKey = instancePath + QLatin1String {"/shared-memory"};
auto sharedMem = new QSharedMemory {sharedMemoryKey, this};
const QString sharedMemoryKey = instancePath.data() + QLatin1String("/shared-memory");
auto sharedMem = new QSharedMemory(sharedMemoryKey, this);
if (m_isFirstInstance)
{
// First instance creates shared memory and store PID