diff --git a/src/blackcore/icaodatareader.cpp b/src/blackcore/icaodatareader.cpp index 9c24f28e7..d2a36da73 100644 --- a/src/blackcore/icaodatareader.cpp +++ b/src/blackcore/icaodatareader.cpp @@ -16,6 +16,7 @@ #include #include #include +#include using namespace BlackMisc; using namespace BlackMisc::Aviation; @@ -326,14 +327,15 @@ namespace BlackCore return (whatToRead & CEntityFlags::AllIcaoAndCountries) == reallyRead; } - CWorker *CIcaoDataReader::readFromJsonFilesInBackground(const QString &dir, CEntityFlags::Entity whatToRead) + bool CIcaoDataReader::readFromJsonFilesInBackground(const QString &dir, CEntityFlags::Entity whatToRead) { - CWorker *worker = BlackMisc::CWorker::fromTask(this, "CIcaoDataReader::readFromJsonFilesInBackground", [this, dir, whatToRead]() + if (dir.isEmpty() || whatToRead == CEntityFlags::NoEntity) { return false; } + QTimer::singleShot(0, this, [this, dir, whatToRead]() { bool s = this->readFromJsonFiles(dir, whatToRead); Q_UNUSED(s); }); - return worker; + return true; } bool CIcaoDataReader::writeToJsonFiles(const QString &dir) const diff --git a/src/blackcore/icaodatareader.h b/src/blackcore/icaodatareader.h index 05dc815d0..6ba416cfc 100644 --- a/src/blackcore/icaodatareader.h +++ b/src/blackcore/icaodatareader.h @@ -105,7 +105,7 @@ namespace BlackCore bool readFromJsonFiles(const QString &dir, BlackMisc::Network::CEntityFlags::Entity whatToRead = BlackMisc::Network::CEntityFlags::AllIcaoAndCountries); //! Read from static DB data file - BlackMisc::CWorker *readFromJsonFilesInBackground(const QString &dir, BlackMisc::Network::CEntityFlags::Entity whatToRead = BlackMisc::Network::CEntityFlags::AllIcaoAndCountries); + bool readFromJsonFilesInBackground(const QString &dir, BlackMisc::Network::CEntityFlags::Entity whatToRead = BlackMisc::Network::CEntityFlags::AllIcaoAndCountries); //! Write to static DB data file bool writeToJsonFiles(const QString &dir) const; diff --git a/src/blackcore/modeldatareader.cpp b/src/blackcore/modeldatareader.cpp index a3b2e034b..9ea92d0d8 100644 --- a/src/blackcore/modeldatareader.cpp +++ b/src/blackcore/modeldatareader.cpp @@ -13,6 +13,7 @@ #include "blackmisc/fileutilities.h" #include "modeldatareader.h" +#include #include #include #include @@ -323,14 +324,15 @@ namespace BlackCore return (reallyRead & CEntityFlags::DistributorLiveryModel) == whatToRead; } - CWorker *CModelDataReader::readFromJsonFilesInBackground(const QString &dir, CEntityFlags::Entity whatToRead) + bool CModelDataReader::readFromJsonFilesInBackground(const QString &dir, CEntityFlags::Entity whatToRead) { - CWorker *worker = BlackMisc::CWorker::fromTask(this, "CModelDataReader::readFromJsonFilesInBackground", [this, dir, whatToRead]() + if (dir.isEmpty() || whatToRead == CEntityFlags::NoEntity) { return false; } + QTimer::singleShot(0, this, [this, dir, whatToRead]() { bool s = this->readFromJsonFiles(dir, whatToRead); Q_UNUSED(s); }); - return worker; + return true; } bool CModelDataReader::writeToJsonFiles(const QString &dir) const diff --git a/src/blackcore/modeldatareader.h b/src/blackcore/modeldatareader.h index 0794a74e2..8418e1447 100644 --- a/src/blackcore/modeldatareader.h +++ b/src/blackcore/modeldatareader.h @@ -97,7 +97,7 @@ namespace BlackCore bool readFromJsonFiles(const QString &dir, BlackMisc::Network::CEntityFlags::Entity whatToRead = BlackMisc::Network::CEntityFlags::DistributorLiveryModel); //! Read from static DB data file - BlackMisc::CWorker *readFromJsonFilesInBackground(const QString &dir, BlackMisc::Network::CEntityFlags::Entity whatToRead = BlackMisc::Network::CEntityFlags::DistributorLiveryModel); + bool readFromJsonFilesInBackground(const QString &dir, BlackMisc::Network::CEntityFlags::Entity whatToRead = BlackMisc::Network::CEntityFlags::DistributorLiveryModel); //! Write to JSON file bool writeToJsonFiles(const QString &dir) const;