diff --git a/src/ui/fortmanager.cpp b/src/ui/fortmanager.cpp index cc36b155..e758fc13 100644 --- a/src/ui/fortmanager.cpp +++ b/src/ui/fortmanager.cpp @@ -267,6 +267,8 @@ void FortManager::install(const char *arg) case 's': { // "service" StartupUtil::setAutoRunMode(StartupUtil::StartupAllUsers); StartupUtil::setServiceInstalled(true); + + OsUtil::endRestartClients(); } break; case 'e': { // "explorer" StartupUtil::setExplorerIntegrated(true); diff --git a/src/ui/manager/autoupdatemanager.cpp b/src/ui/manager/autoupdatemanager.cpp index 3d9c423c..da944d96 100644 --- a/src/ui/manager/autoupdatemanager.cpp +++ b/src/ui/manager/autoupdatemanager.cpp @@ -83,7 +83,7 @@ void AutoUpdateManager::setupRestart() { if (IoC()->isService()) { connect(IoC(), &ServiceManager::stopRestartingRequested, this, - &AutoUpdateManager::restartClients); + &AutoUpdateManager::onRestartClientsRequested); } else { if (!OsUtil::registerAppRestart()) { qCWarning(LC) << "Restart registration error"; @@ -146,6 +146,15 @@ void AutoUpdateManager::setupByTaskInfo(TaskInfoUpdateChecker *taskInfo) setIsDownloaded(downloaded); } +void AutoUpdateManager::onRestartClientsRequested(bool restarting) +{ + if (restarting) { + OsUtil::beginRestartClients(); + } + + emit restartClients(restarting); +} + void AutoUpdateManager::clearUpdateDir() { if (isDownloaded()) diff --git a/src/ui/manager/autoupdatemanager.h b/src/ui/manager/autoupdatemanager.h index 95b155c7..d5a62b00 100644 --- a/src/ui/manager/autoupdatemanager.h +++ b/src/ui/manager/autoupdatemanager.h @@ -74,6 +74,8 @@ protected slots: private: void setupByTaskInfo(TaskInfoUpdateChecker *taskInfo); + void onRestartClientsRequested(bool restarting); + void clearUpdateDir(); bool saveInstaller(const QByteArray &fileData); diff --git a/src/ui/util/osutil.cpp b/src/ui/util/osutil.cpp index 78879d1a..d6b819b6 100644 --- a/src/ui/util/osutil.cpp +++ b/src/ui/util/osutil.cpp @@ -180,6 +180,16 @@ bool OsUtil::registerAppRestart() RegisterApplicationRestart(L"--restarted", RESTART_NO_CRASH | RESTART_NO_REBOOT)); } +void OsUtil::beginRestartClients() +{ + FileUtil::writeFileData(FileUtil::appBinLocation() + "/inst.tmp", {}); +} + +void OsUtil::endRestartClients() +{ + FileUtil::removeFile(FileUtil::appBinLocation() + "/inst.tmp"); +} + void OsUtil::restartClient() { const QFileInfo fi(QCoreApplication::applicationFilePath()); diff --git a/src/ui/util/osutil.h b/src/ui/util/osutil.h index 582f6efa..ec178b5f 100644 --- a/src/ui/util/osutil.h +++ b/src/ui/util/osutil.h @@ -44,7 +44,10 @@ public: static bool registerAppRestart(); + static void beginRestartClients(); + static void endRestartClients(); static void restartClient(); + static void restart(); static void quit(const QString &reason); };