Commit 5980a1e3 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Do not create pid-specific peer file before initialize



When running with -client, pidPeer file is created too early,
and it is not locked, therefore never deleted.

initialize() is called for non-client executions (including the case
of qtcreator -client when no instance is running or qtcreator -client
-pid when the pid is invalid).

Task-number: QTCREATORBUG-9216
Change-Id: I825556b0ec5e1db4240e4a63bfe6aec60386984d
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarnetyrj <netyrj@gmail.com>
parent 29597d36
...@@ -52,7 +52,8 @@ static QString instancesLockFilename(const QString &appSessionId) ...@@ -52,7 +52,8 @@ static QString instancesLockFilename(const QString &appSessionId)
QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv) QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv)
: QApplication(argc, argv), : QApplication(argc, argv),
firstPeer(-1) firstPeer(-1),
pidPeer(0)
{ {
this->appId = appId; this->appId = appId;
...@@ -62,10 +63,6 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char * ...@@ -62,10 +63,6 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char *
instances = new QSharedMemory(appSessionId, this); instances = new QSharedMemory(appSessionId, this);
actWin = 0; actWin = 0;
block = false; block = false;
const qint64 appPid = QCoreApplication::applicationPid();
pidPeer = new QtLocalPeer(this, appId + QLatin1Char('-') + QString::number(appPid));
connect(pidPeer, SIGNAL(messageReceived(QString,QObject*)), SIGNAL(messageReceived(QString,QObject*)));
// First instance creates the shared memory, later instances attach to it // First instance creates the shared memory, later instances attach to it
const bool created = instances->create(instancesSize); const bool created = instances->create(instancesSize);
...@@ -78,6 +75,7 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char * ...@@ -78,6 +75,7 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char *
return; return;
} }
} }
// QtLockedFile is used to workaround QTBUG-10364 // QtLockedFile is used to workaround QTBUG-10364
QtLockedFile lockfile(instancesLockFilename(appSessionId)); QtLockedFile lockfile(instancesLockFilename(appSessionId));
...@@ -93,7 +91,7 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char * ...@@ -93,7 +91,7 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char *
} }
} }
// Add current pid to list and terminate it // Add current pid to list and terminate it
*pids++ = appPid; *pids++ = QCoreApplication::applicationPid();
*pids = 0; *pids = 0;
lockfile.unlock(); lockfile.unlock();
} }
...@@ -141,6 +139,9 @@ bool QtSingleApplication::isRunning(qint64 pid) ...@@ -141,6 +139,9 @@ bool QtSingleApplication::isRunning(qint64 pid)
void QtSingleApplication::initialize(bool) void QtSingleApplication::initialize(bool)
{ {
pidPeer = new QtLocalPeer(this, appId + QLatin1Char('-') +
QString::number(QCoreApplication::applicationPid()));
connect(pidPeer, SIGNAL(messageReceived(QString,QObject*)), SIGNAL(messageReceived(QString,QObject*)));
pidPeer->isClient(); pidPeer->isClient();
} }
...@@ -169,6 +170,8 @@ void QtSingleApplication::setBlock(bool value) ...@@ -169,6 +170,8 @@ void QtSingleApplication::setBlock(bool value)
void QtSingleApplication::setActivationWindow(QWidget *aw, bool activateOnMessage) void QtSingleApplication::setActivationWindow(QWidget *aw, bool activateOnMessage)
{ {
actWin = aw; actWin = aw;
if (!pidPeer)
return;
if (activateOnMessage) if (activateOnMessage)
connect(pidPeer, SIGNAL(messageReceived(QString,QObject*)), this, SLOT(activateWindow())); connect(pidPeer, SIGNAL(messageReceived(QString,QObject*)), this, SLOT(activateWindow()));
else else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment