mirror of
https://github.com/itay-grudev/SingleApplication.git
synced 2025-01-15 08:52:08 +08:00
Fixed new line issue
This commit is contained in:
parent
5e5d92e058
commit
ff14d2b59d
@ -2,8 +2,7 @@
|
||||
#include <cstdlib>
|
||||
|
||||
/**
|
||||
* @brief Constructor. Checks and fires up LocalServer or closes the
|
||||
program
|
||||
* @brief Constructor. Checks and fires up LocalServer or closes the program
|
||||
* if another instance already exists
|
||||
* @param argc
|
||||
* @param argv
|
||||
@ -11,8 +10,7 @@ program
|
||||
SingleApplication::SingleApplication(int argc, char *argv[])
|
||||
: QApplication(argc, argv)
|
||||
{
|
||||
QString serverName = QApplication::organizationName() +
|
||||
QApplication::applicationName();
|
||||
QString serverName = QApplication::organizationName() + QApplication::applicationName();
|
||||
serverName.replace(QRegExp("[^\\w\\-. ]"), "");
|
||||
|
||||
// Attempt to connect to the LocalServer
|
||||
@ -20,16 +18,14 @@ QApplication::applicationName();
|
||||
socket->connectToServer(serverName);
|
||||
if(socket->waitForConnected(1000)){
|
||||
socket->close();
|
||||
::exit(EXIT_SUCCESS); // Terminate the program using STDLib's
|
||||
exit function
|
||||
::exit(EXIT_SUCCESS); // Terminate the program using STDLib's exit function
|
||||
} else {
|
||||
// If the connection is insuccessful, this is the main process
|
||||
// So we create a Local Server
|
||||
server = new QLocalServer();
|
||||
server->removeServer(serverName);
|
||||
server->listen(serverName);
|
||||
QObject::connect(server, SIGNAL(newConnection()), this,
|
||||
SLOT(slotConnectionEstablished()));
|
||||
QObject::connect(server, SIGNAL(newConnection()), this, SLOT(slotConnectionEstablished()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,4 +45,3 @@ void SingleApplication::slotConnectionEstablished()
|
||||
server->nextPendingConnection();
|
||||
emit showUp();
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,7 @@
|
||||
#include <QLocalServer>
|
||||
|
||||
/**
|
||||
* @brief The SingleApplication class handles multipe instances of the
|
||||
same Application
|
||||
* @brief The SingleApplication class handles multipe instances of the same Application
|
||||
* @see QApplication
|
||||
*/
|
||||
class SingleApplication : public QApplication
|
||||
@ -30,4 +29,3 @@ private:
|
||||
};
|
||||
|
||||
#endif // SINGLE_APPLICATION_H
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user