UI: Confirm restart on DB error

This commit is contained in:
Nodir Temirkhodjaev 2024-01-11 17:28:36 +03:00
parent 991ff38c10
commit 4878582b61
5 changed files with 27 additions and 17 deletions

View File

@ -422,10 +422,16 @@ void FortManager::show()
void FortManager::processRestartRequired()
{
auto windowManager = IoC<WindowManager>();
auto settings = IoC<FortSettings>();
windowManager->showConfirmBox(
[=] { windowManager->restart(); }, tr("Restart Now?"), tr("Restart Required"));
if (settings->isService()) {
IoC<ServiceManager>()->restart();
} else {
auto windowManager = IoC<WindowManager>();
windowManager->showConfirmBox(
[=] { windowManager->restart(); }, tr("Restart Now?"), tr("Restart Required"));
}
}
void FortManager::loadConf()

View File

@ -5,8 +5,8 @@
#include <sqlite/sqlitedb.h>
#include <fortmanager.h>
#include <fortsettings.h>
#include <manager/windowmanager.h>
#include <util/fileutil.h>
#include <util/ioc/ioccontainer.h>
@ -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<FortSettings>();
// 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<WindowManager>()->restart();
IoC<FortManager>()->processRestartRequired();
return;
}

View File

@ -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;
};

View File

@ -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();
}

View File

@ -30,6 +30,8 @@ public:
void processControl(quint32 code, quint32 eventType) override;
void restart();
signals:
void pauseRequested();
void continueRequested();