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