mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 15:07:22 -06:00
Create lock file in config folder instead of temp folder
Some linux distros seem to alter TMPDIR environment variable and therefore hamper qbt ability to find the lock files. So use config folder instead of TMPDIR folder to create/locate the lock files. Note that this change will also make qbt become one instance per-user instead of one instance per-system. Closes #15646.
This commit is contained in:
@@ -28,24 +28,27 @@
|
||||
|
||||
#include "applicationinstancemanager.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSharedMemory>
|
||||
#endif
|
||||
|
||||
#include "qtlocalpeer/qtlocalpeer.h"
|
||||
|
||||
ApplicationInstanceManager::ApplicationInstanceManager(const QString &appId, QObject *parent)
|
||||
ApplicationInstanceManager::ApplicationInstanceManager(const QString &instancePath, QObject *parent)
|
||||
: QObject {parent}
|
||||
, m_peer {new QtLocalPeer {this, appId}}
|
||||
, m_peer {new QtLocalPeer {instancePath, this}}
|
||||
, m_isFirstInstance {!m_peer->isClient()}
|
||||
{
|
||||
connect(m_peer, &QtLocalPeer::messageReceived, this, &ApplicationInstanceManager::messageReceived);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
auto sharedMem = new QSharedMemory {appId + QLatin1String {"-shared-memory-key"}, this};
|
||||
const QString sharedMemoryKey = instancePath + QLatin1String {"/shared-memory"};
|
||||
auto sharedMem = new QSharedMemory {sharedMemoryKey, this};
|
||||
if (m_isFirstInstance)
|
||||
{
|
||||
// First instance creates shared memory and store PID
|
||||
@@ -79,8 +82,3 @@ bool ApplicationInstanceManager::sendMessage(const QString &message, const int t
|
||||
{
|
||||
return m_peer->sendMessage(message, timeout);
|
||||
}
|
||||
|
||||
QString ApplicationInstanceManager::appId() const
|
||||
{
|
||||
return m_peer->applicationId();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user