From 178a068ad06e8c08a3b769fe0d5c7913ef1b3534 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 17 Mar 2018 10:21:00 +0100 Subject: Try starting the synchronizer with an absolute path, and fallback to PATH Otherwise we don't find the binary in a MacOS bundle. --- common/resourceaccess.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 201c023..2846b23 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp @@ -215,16 +215,27 @@ KAsync::Job ResourceAccess::Private::initializeSocket() return KAsync::error(); } args << resourceInstanceIdentifier << resourceName; + + //Prefer a binary next to this binary, otherwise fall-back to PATH. Necessary for MacOS bundles because the bundle is not in the PATH. + const QString synchronizerBinaryName = "sink_synchronizer"; + QString synchronizerBinary = [&]() { + const auto path = QCoreApplication::applicationDirPath() + QDir::separator() + synchronizerBinaryName; + if (QFileInfo{path}.isExecutable()) { + return path; + } else { + return synchronizerBinaryName; + } + }(); qint64 pid = 0; - if (QProcess::startDetached("sink_synchronizer", args, QDir::homePath(), &pid)) { + if (QProcess::startDetached(synchronizerBinary, args, QDir::homePath(), &pid)) { SinkTrace() << "Started resource " << pid; return tryToConnect() .onError([this, args](const KAsync::Error &error) { SinkWarning() << "Failed to connect to started resource: sink_synchronizer " << args; }); } else { - SinkWarning() << "Failed to start resource"; - return KAsync::error(-1, "Failed to start resource"); + SinkError() << "Failed to start resource"; + return KAsync::error(-1, "Failed to start resource."); } } else { SinkTrace() << "Connected to resource, without having to start it."; -- cgit v1.2.3