Merge pull request #342 from PhenomRetroShare/Fix_AllowOnlyOneInst

Fix Allow Only One Instance
This commit is contained in:
Cyril Soler 2016-04-08 20:41:12 -04:00
commit 85c8274f47

View file

@ -128,7 +128,7 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir)
{
QString serverName = QString(TARGET);
if (args.isEmpty()) args.append("Empty");
if (!args.isEmpty()) {
// load into shared memory
QBuffer buffer;
buffer.open(QBuffer::ReadWrite);
@ -168,15 +168,16 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir)
localSocket.waitForDisconnected(1000);
newArgs.detach();
::exit(EXIT_SUCCESS); // Terminate the program using STDLib's exit function
} else {
}
newArgs.detach();
}
// No main process exists
// Or started without arguments
// So we start a Local Server to listen for connections from new process
localServer= new QLocalServer();
QObject::connect(localServer, SIGNAL(newConnection()), this, SLOT(slotConnectionEstablished()));
updateLocalServer();
}
}
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
qInstallMessageHandler(qt_msg_handler);