diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-03-17 10:28:19 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-03-17 10:28:19 +0100 |
commit | 824d30caf506eb95dd1943d9bd86194f04e6214c (patch) | |
tree | 44ef2b0ca533fa09c1742575953acc5ae402a6fb | |
parent | 178a068ad06e8c08a3b769fe0d5c7913ef1b3534 (diff) | |
download | sink-824d30caf506eb95dd1943d9bd86194f04e6214c.tar.gz sink-824d30caf506eb95dd1943d9bd86194f04e6214c.zip |
QStandardPaths has a function to find executables.
-rw-r--r-- | common/resourceaccess.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 2846b23..85dda6d 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <QDataStream> | 46 | #include <QDataStream> |
47 | #include <QBuffer> | 47 | #include <QBuffer> |
48 | #include <QTime> | 48 | #include <QTime> |
49 | #include <QStandardPaths> | ||
49 | 50 | ||
50 | static void queuedInvoke(const std::function<void()> &f, QObject *context = 0) | 51 | static void queuedInvoke(const std::function<void()> &f, QObject *context = 0) |
51 | { | 52 | { |
@@ -217,17 +218,8 @@ KAsync::Job<void> ResourceAccess::Private::initializeSocket() | |||
217 | args << resourceInstanceIdentifier << resourceName; | 218 | args << resourceInstanceIdentifier << resourceName; |
218 | 219 | ||
219 | //Prefer a binary next to this binary, otherwise fall-back to PATH. Necessary for MacOS bundles because the bundle is not in the PATH. | 220 | //Prefer a binary next to this binary, otherwise fall-back to PATH. Necessary for MacOS bundles because the bundle is not in the PATH. |
220 | const QString synchronizerBinaryName = "sink_synchronizer"; | ||
221 | QString synchronizerBinary = [&]() { | ||
222 | const auto path = QCoreApplication::applicationDirPath() + QDir::separator() + synchronizerBinaryName; | ||
223 | if (QFileInfo{path}.isExecutable()) { | ||
224 | return path; | ||
225 | } else { | ||
226 | return synchronizerBinaryName; | ||
227 | } | ||
228 | }(); | ||
229 | qint64 pid = 0; | 221 | qint64 pid = 0; |
230 | if (QProcess::startDetached(synchronizerBinary, args, QDir::homePath(), &pid)) { | 222 | if (QProcess::startDetached(QStandardPaths::findExecutable("sink_synchronizer", {QCoreApplication::applicationDirPath()}), args, QDir::homePath(), &pid)) { |
231 | SinkTrace() << "Started resource " << pid; | 223 | SinkTrace() << "Started resource " << pid; |
232 | return tryToConnect() | 224 | return tryToConnect() |
233 | .onError([this, args](const KAsync::Error &error) { | 225 | .onError([this, args](const KAsync::Error &error) { |