aboutsummaryrefslogtreecommitdiff
path: root/src/main.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/main.cpp
parentProfile menu lists loadable profiles (diff)
downloadsmolbote-705249718c3172cf845f8525d9867a29fe1240fa.tar.xz
Always connect to local socket
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/main.cpp b/src/main.cpp
index e29e547..6efb882 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -77,23 +77,26 @@ int main(int argc, char **argv)
}
// check for other instances
- // if we socket hasn't been disabled (socket is not none)
- if(parser.value(parser.socketOption) != "none") {
- bool bindOk = instance.bindLocalSocket(parser.value(parser.socketOption));
- if(bindOk) {
- qDebug("Connected to local socket: %s", qUtf8Printable(instance.serverName()));
- } else {
- // pass arguments to new instance
- return instance.sendMessage(parser.value(parser.profileOption), parser.isSet(parser.newWindowOption), parser.positionalArguments());
- }
+ bool isSingleInstance = instance.bindLocalSocket(parser.value(parser.socketOption));
+ qDebug("Connected to local socket %s: %s", qUtf8Printable(instance.serverName()), isSingleInstance ? "ok" : "failed");
+ if(isSingleInstance) {
+ instance.setConfiguration(config);
}
- instance.setConfiguration(config);
+ // create session
+ {
+ QString profile;
+ if(parser.isSet(parser.profileOption))
+ profile = parser.value(parser.profileOption);
+ else
+ profile = QString::fromStdString(config->value<std::string>("browser.profile").value());
+
+ instance.sendMessage(profile, parser.isSet(parser.newWindowOption), parser.positionalArguments());
+ }
- if(parser.isSet(parser.profileOption))
- instance.createSession(parser.value(parser.profileOption), parser.isSet(parser.newWindowOption), parser.positionalArguments());
- else
- instance.createSession(QString::fromStdString(config->value<std::string>("browser.profile").value()), parser.isSet(parser.newWindowOption), parser.positionalArguments());
+ if(!isSingleInstance) {
+ return 0;
+ }
#ifdef QT_DEBUG
qDebug("Startup complete in %lldms", timer.elapsed());