From fe4c161cb6db9a8b413ed692d905bbf35bc8103e Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 14 Jan 2016 12:44:52 -0800 Subject: [PATCH] Fix sending URL to second interface instance --- interface/src/main.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 43835524ce..90ac6223fc 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -78,8 +78,11 @@ int main(int argc, const char* argv[]) { if (parser.isSet(urlOption)) { QUrl url = QUrl(parser.value(urlOption)); if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) { + qDebug() << "Writing URL to local socket"; socket.write(url.toString().toUtf8()); - socket.waitForBytesWritten(5000); + if (!socket.waitForBytesWritten(5000)) { + qDebug() << "Error writing URL to local socket"; + } } } @@ -95,12 +98,6 @@ int main(int argc, const char* argv[]) { #endif } - // Setup local server - QLocalServer server; - - // We failed to connect to a local server, so we remove any existing servers. - server.removeServer(applicationName); - server.listen(applicationName); QElapsedTimer startupTime; startupTime.start(); @@ -125,6 +122,13 @@ int main(int argc, const char* argv[]) { QSettings::setDefaultFormat(QSettings::IniFormat); Application app(argc, const_cast(argv), startupTime); + // Setup local server + QLocalServer server { &app }; + + // We failed to connect to a local server, so we remove any existing servers. + server.removeServer(applicationName); + server.listen(applicationName); + QObject::connect(&server, &QLocalServer::newConnection, &app, &Application::handleLocalServerConnection); QTranslator translator;