mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-21 23:40:26 -04:00
Fix Allow Only One Instance
If RS_GUI is started without arguments, it is started with a new instance.
This commit is contained in:
parent
c8cae4c33c
commit
08e5679019
1 changed files with 41 additions and 40 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue