diff --git a/src/ui/fortmanager.cpp b/src/ui/fortmanager.cpp index efa21c54..68451308 100644 --- a/src/ui/fortmanager.cpp +++ b/src/ui/fortmanager.cpp @@ -422,10 +422,16 @@ void FortManager::show() void FortManager::processRestartRequired() { - auto windowManager = IoC(); + auto settings = IoC(); - windowManager->showConfirmBox( - [=] { windowManager->restart(); }, tr("Restart Now?"), tr("Restart Required")); + if (settings->isService()) { + IoC()->restart(); + } else { + auto windowManager = IoC(); + + windowManager->showConfirmBox( + [=] { windowManager->restart(); }, tr("Restart Now?"), tr("Restart Required")); + } } void FortManager::loadConf() diff --git a/src/ui/manager/dberrormanager.cpp b/src/ui/manager/dberrormanager.cpp index b785b557..7b5ef04c 100644 --- a/src/ui/manager/dberrormanager.cpp +++ b/src/ui/manager/dberrormanager.cpp @@ -5,8 +5,8 @@ #include +#include #include -#include #include #include @@ -30,17 +30,14 @@ void sqliteLogHandler(void *context, int errCode, const char *message) DbErrorManager::DbErrorManager(QObject *parent) : QObject(parent) { } void DbErrorManager::setUp() -{ - setupDriveMask(); - - SqliteDb::setErrorLogCallback(sqliteLogHandler, /*context=*/this); -} - -void DbErrorManager::setupDriveMask() { auto settings = IoC(); + // Drive Mask m_driveMask |= FileUtil::driveMaskByPath(settings->confFilePath()); + + // SQLite Log Callback + SqliteDb::setErrorLogCallback(sqliteLogHandler, /*context=*/this); } void DbErrorManager::onDbIoError() @@ -59,7 +56,7 @@ void DbErrorManager::checkDriveList() if (m_driveMask == driveMask) { // Restart on profile drive mounted - IoC()->restart(); + IoC()->processRestartRequired(); return; } diff --git a/src/ui/manager/dberrormanager.h b/src/ui/manager/dberrormanager.h index a9dd52ec..9e653428 100644 --- a/src/ui/manager/dberrormanager.h +++ b/src/ui/manager/dberrormanager.h @@ -21,10 +21,7 @@ private slots: void checkDriveList(); private: - void setupDriveMask(); - -private: - bool m_polling = false; + bool m_polling : 1 = false; quint32 m_driveMask = 0; }; diff --git a/src/ui/manager/servicemanager.cpp b/src/ui/manager/servicemanager.cpp index cee683bd..da438b34 100644 --- a/src/ui/manager/servicemanager.cpp +++ b/src/ui/manager/servicemanager.cpp @@ -49,6 +49,8 @@ void ServiceManager::initialize(qintptr hstatus) ServiceManagerIface::initialize(hstatus); registerDeviceNotification(); + + qApp->connect(qApp, &QObject::destroyed, [] { reportStatus(SERVICE_STOPPED); }); } void ServiceManager::setupControlManager() @@ -113,7 +115,6 @@ void ServiceManager::processControl(quint32 code, quint32 eventType) case SERVICE_CONTROL_SHUTDOWN: { qCDebug(LC) << "Quit due service control"; - qApp->connect(qApp, &QObject::destroyed, [] { reportStatus(SERVICE_STOPPED); }); QCoreApplication::quit(); // it's threadsafe state = SERVICE_STOP_PENDING; @@ -127,3 +128,10 @@ void ServiceManager::processControl(quint32 code, quint32 eventType) reportStatus(state); } + +void ServiceManager::restart() +{ + qCDebug(LC) << "Quit due required restart"; + + QCoreApplication::quit(); +} diff --git a/src/ui/manager/servicemanager.h b/src/ui/manager/servicemanager.h index 2adc6cbf..63c60ac2 100644 --- a/src/ui/manager/servicemanager.h +++ b/src/ui/manager/servicemanager.h @@ -30,6 +30,8 @@ public: void processControl(quint32 code, quint32 eventType) override; + void restart(); + signals: void pauseRequested(); void continueRequested();