From be9260fcc2cfb7a9b84de214d4942f1ed650939a Mon Sep 17 00:00:00 2001 From: Weixuan XIAO Date: Sat, 16 Nov 2019 13:44:52 +0100 Subject: [PATCH] Add return code --- indicator/indicatorhelper.cpp | 13 ++++++++++--- indicator/indicatorhelper.h | 6 +++--- indicator/main.cpp | 5 ++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/indicator/indicatorhelper.cpp b/indicator/indicatorhelper.cpp index 0b00b1afc..13b4110be 100644 --- a/indicator/indicatorhelper.cpp +++ b/indicator/indicatorhelper.cpp @@ -41,9 +41,11 @@ void IndicatorHelper::postInit() {} void IndicatorHelper::iconPathHook() {} -void IndicatorHelper::daemonHook(QProcess &kdeconnectd) +int IndicatorHelper::daemonHook(QProcess &kdeconnectd) { Q_UNUSED(kdeconnectd); + + return 0; } #ifdef QSYSTRAY @@ -80,7 +82,7 @@ void MacOSIndicatorHelper::iconPathHook() } } -void MacOSIndicatorHelper::daemonHook(QProcess &kdeconnectd) +int MacOSIndicatorHelper::daemonHook(QProcess &kdeconnectd) { // Unset launchctl env, avoid block @@ -97,6 +99,7 @@ void MacOSIndicatorHelper::daemonHook(QProcess &kdeconnectd) i18n("Cannot find kdeconnectd"), QMessageBox::Abort, QMessageBox::Abort); + return -1; } // Wait for dbus daemon env @@ -125,6 +128,7 @@ void MacOSIndicatorHelper::daemonHook(QProcess &kdeconnectd) "KDE Connect will quit"), QMessageBox::Abort, QMessageBox::Abort); + return -2; } else { QThread::sleep(3); // Retry after 3s retry++; @@ -132,6 +136,8 @@ void MacOSIndicatorHelper::daemonHook(QProcess &kdeconnectd) } while(true); m_splashScreen->showMessage(i18n("Loading modules") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::white); + + return 0; } #ifdef QSYSTRAY @@ -155,9 +161,10 @@ void MacOSIndicatorHelper::systrayIconHook(KStatusNotifierItem &systray) WindowsIndicatorHelper::WindowsIndicatorHelper() {} WindowsIndicatorHelper::~WindowsIndicatorHelper() {} -void WindowsIndicatorHelper::daemonHook(QProcess &kdeconnectd) +int WindowsIndicatorHelper::daemonHook(QProcess &kdeconnectd) { kdeconnectd.start(QStringLiteral("kdeconnectd.exe")); + return 0; } #ifdef QSYSTRAY diff --git a/indicator/indicatorhelper.h b/indicator/indicatorhelper.h index 26ddca48b..dfb68df43 100644 --- a/indicator/indicatorhelper.h +++ b/indicator/indicatorhelper.h @@ -38,7 +38,7 @@ public: virtual void iconPathHook(); - virtual void daemonHook(QProcess &kdeconnectd); + virtual int daemonHook(QProcess &kdeconnectd); #ifdef QSYSTRAY virtual void systrayIconHook(QSystemTrayIcon &systray); @@ -56,7 +56,7 @@ public: void iconPathHook(); - void daemonHook(QProcess &kdeconnectd); + int daemonHook(QProcess &kdeconnectd); #ifdef QSYSTRAY void systrayIconHook(QSystemTrayIcon &systray); @@ -74,7 +74,7 @@ public: WindowsIndicatorHelper(); ~WindowsIndicatorHelper(); - void daemonHook(QProcess &kdeconnectd); + int daemonHook(QProcess &kdeconnectd); #ifdef QSYSTRAY void systrayIconHook(QSystemTrayIcon &systray); diff --git a/indicator/main.cpp b/indicator/main.cpp index a09b4ff7c..1e81096a0 100644 --- a/indicator/main.cpp +++ b/indicator/main.cpp @@ -66,7 +66,10 @@ int main(int argc, char** argv) // Run Daemon initilization step QProcess kdeconnectd; - helper->daemonHook(kdeconnectd); + if (helper->daemonHook(kdeconnectd)) { + delete helper; + return -1; + } KDBusService dbusService(KDBusService::Unique);