Fix bug, about application collapse by

db can't connect
This commit is contained in:
kradchen
2023-11-13 17:54:40 +08:00
parent 654633b16b
commit 9702db1d58
7 changed files with 51 additions and 135 deletions

View File

@@ -18,6 +18,7 @@
#include "src/utilities/LanguageSwitcher.h"
#include "utilities/TouchScreenSignalSender.h"
#include "keyboard/KeyboardManager.h"
#include "appvals/AppGlobalValues.h"
QString loadFontFromFile(QString path)
{
@@ -74,14 +75,7 @@ int main(int argc, char* argv[])
{
a.setStyleSheet(QLatin1String(file.readAll()));
}
bool sqlConnected= SQLHelper::Open();
if (!sqlConnected)
{
//TODO: 数据库连接失败错误
exit(-99);
}
AppGlobalValues::setDBconnected(false);
MainWindow w;
DialogManager::Default()->init(&w);
UserOperationLog::Default()->init();
@@ -98,37 +92,10 @@ int main(int argc, char* argv[])
KeyboardManager::getInstance();
UserOperationLog::cleanHistoryLog();
if (app_args.contains("-d"))
//if (true)
{
w.showFullScreen();
DeviceManager::Default()->initDevice();
w.debugConsoleOn();
w.showFullScreen();
qInstallMessageHandler(MainWindow::QMessageOutput);
QThread thread;
StdOutRedirector redir;
redir.setOutputTF(w.getEdit());
QTimer Timer;
redir.moveToThread(&thread);
QObject::connect(&Timer, SIGNAL(timeout()), &redir, SLOT(readOutsToTF()));
fflush(stdout);
Timer.start(1000);
thread.start();
DeviceManager::Default()->initDevice();
ret = a.exec();
thread.terminate();
}
else
{
w.showFullScreen();
DeviceManager::Default()->initDevice();
ret = a.exec();
}
ret = a.exec();
DeviceManager::Default()->close();
return ret;
}