|
@@ -7,6 +7,7 @@
|
|
|
#include <QFontDatabase>
|
|
|
#include <QMessageLogContext>
|
|
|
#include <QApplication>
|
|
|
+#include <QtConcurrent/QtConcurrent>
|
|
|
|
|
|
#include "utils.h"
|
|
|
#include "widgets/mainwindow.h"
|
|
@@ -18,6 +19,8 @@ extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
|
|
|
|
|
|
|
|
LegacyApplication::LegacyApplication() {
|
|
|
+ qRegisterMetaType<AppErrorStatus>();
|
|
|
+
|
|
|
qInstallMessageHandler(logMessageHandler);
|
|
|
|
|
|
modules_init_timer_.setInterval(1 * 1000); // one second.
|
|
@@ -66,6 +69,15 @@ bool LegacyApplication::init() {
|
|
|
gui = new MainWindow();
|
|
|
|
|
|
qDebug() << "Starting functional modules initialisation...";
|
|
|
+ connect(this, &LegacyApplication::ErrorStatusChanged, this, [this](AppErrorStatus status){
|
|
|
+ if (status == E_NO_SERVER_CONNECTION) {
|
|
|
+ qWarning() << "LegacyApplication: Cannot connect to server - restarting in 1 second!";
|
|
|
+ modules_init_timer_.start();
|
|
|
+ } else if (status == E_LOTRO_RUNNING) {
|
|
|
+ qWarning() << "LegacyApplication: found running lotro instance!";
|
|
|
+ modules_init_timer_.start();
|
|
|
+ }
|
|
|
+ });
|
|
|
InitModules();
|
|
|
|
|
|
qDebug() << "Successfully finished the initialization!!!";
|
|
@@ -74,18 +86,19 @@ bool LegacyApplication::init() {
|
|
|
|
|
|
void LegacyApplication::InitModules() {
|
|
|
modules_init_timer_.stop();
|
|
|
- AppErrorStatus status = CheckAppPrerequesities();
|
|
|
- emit ErrorStatusChanged(status);
|
|
|
- qDebug() << "NEW ERROR STATUS: " << status;
|
|
|
-
|
|
|
- if (status == E_NO_ERRORS) {
|
|
|
- QMetaObject::invokeMethod(&PatchInstaller::instance(), &PatchInstaller::init, Qt::BlockingQueuedConnection);
|
|
|
- QMetaObject::invokeMethod(&PatchDownloader::instance(), &PatchDownloader::init, Qt::BlockingQueuedConnection);
|
|
|
- QMetaObject::invokeMethod(&PatchDownloader::instance(), &PatchDownloader::checkForUpdates, Qt::QueuedConnection);
|
|
|
- } else if (status == E_NO_SERVER_CONNECTION) {
|
|
|
- qWarning() << "LegacyApplication: Cannot connect to server - restarting in 1 second!";
|
|
|
- modules_init_timer_.start();
|
|
|
- }
|
|
|
+
|
|
|
+ QtConcurrent::run([this]() {
|
|
|
+ emit ModulesInitializationStarted();
|
|
|
+ AppErrorStatus status = CheckAppPrerequesities();
|
|
|
+ emit ErrorStatusChanged(status);
|
|
|
+ qDebug() << "NEW ERROR STATUS: " << status;
|
|
|
+
|
|
|
+ if (status == E_NO_ERRORS) {
|
|
|
+ QMetaObject::invokeMethod(&PatchInstaller::instance(), &PatchInstaller::init, Qt::BlockingQueuedConnection);
|
|
|
+ QMetaObject::invokeMethod(&PatchDownloader::instance(), &PatchDownloader::init, Qt::BlockingQueuedConnection);
|
|
|
+ QMetaObject::invokeMethod(&PatchDownloader::instance(), &PatchDownloader::checkForUpdates, Qt::QueuedConnection);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
void LegacyApplication::close() {
|