From 621ae3e007aab6aedaacd2149b49d1515900908f Mon Sep 17 00:00:00 2001 From: Weixuan Xiao Date: Fri, 4 Aug 2023 08:55:26 +0000 Subject: [PATCH] Fix potential race condition --- core/dbushelper.cpp | 1 + indicator/indicatorhelper_mac.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/core/dbushelper.cpp b/core/dbushelper.cpp index e78bb1659..a2e49770e 100644 --- a/core/dbushelper.cpp +++ b/core/dbushelper.cpp @@ -96,6 +96,7 @@ void DBusInstancePrivate::launchDBusDaemon() m_dbusProcess->setStandardOutputFile(KdeConnectConfig::instance().privateDBusAddressPath()); m_dbusProcess->setStandardErrorFile(QProcess::nullDevice()); m_dbusProcess->start(); + m_dbusProcess->waitForStarted(); // Avoid potential racing condition #ifdef Q_OS_MAC // Set launchctl env diff --git a/indicator/indicatorhelper_mac.cpp b/indicator/indicatorhelper_mac.cpp index eb8a604eb..cfd1e2550 100644 --- a/indicator/indicatorhelper_mac.cpp +++ b/indicator/indicatorhelper_mac.cpp @@ -112,6 +112,8 @@ int IndicatorHelper::daemonHook(QProcess &kdeconnectd) "KDE Connect will quit"), QMessageBox::Abort, QMessageBox::Abort); + // End the program + return -1; } else { // Show a warning and exit qCritical() << "Fail to get launchctl" << KDECONNECT_SESSION_DBUS_LAUNCHD_ENV << "env";