aboutsummaryrefslogtreecommitdiff
path: root/src/singleapplication.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-01-30 19:23:34 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-01-30 19:23:34 +0100
commit705249718c3172cf845f8525d9867a29fe1240fa (patch)
tree7fafee76b2d371284ebd9ad8ba011df1e7664eab /src/singleapplication.cpp
parentProfile menu lists loadable profiles (diff)
downloadsmolbote-705249718c3172cf845f8525d9867a29fe1240fa.tar.xz
Always connect to local socket
Diffstat (limited to 'src/singleapplication.cpp')
-rw-r--r--src/singleapplication.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/singleapplication.cpp b/src/singleapplication.cpp
index 2356fc2..720690d 100644
--- a/src/singleapplication.cpp
+++ b/src/singleapplication.cpp
@@ -14,13 +14,6 @@
SingleApplication::SingleApplication(int &argc, char **argv)
: QApplication(argc, argv)
{
-#ifdef Q_OS_UNIX
- // could be a path such as "/tmp/foo"
- LOCALSERVER_KEY = "smolbote_socket";
-#elif Q_OS_WIN32
- // could be a pipe path such as "\\.\pipe\foo"
- LOCALSERVER_KEY = "\\.\pipe\smolbote_socket";
-#endif
}
SingleApplication::~SingleApplication()
@@ -39,10 +32,7 @@ SingleApplication::~SingleApplication()
*/
bool SingleApplication::bindLocalSocket(const QString &name)
{
- // if a name has been set
- if(!name.isEmpty()) {
- LOCALSERVER_KEY = name;
- }
+ LOCALSERVER_KEY = name;
QLocalSocket socket;
socket.connectToServer(LOCALSERVER_KEY);
@@ -60,11 +50,7 @@ bool SingleApplication::bindLocalSocket(const QString &name)
// no other server
QLocalServer::removeServer(LOCALSERVER_KEY);
- if(!m_localServer->listen(LOCALSERVER_KEY)) {
- // for some reason, we still can't bind the socket
- return false;
- }
- return true;
+ return m_localServer->listen(LOCALSERVER_KEY);
}
}