mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
refs #483, call in background via QTimer::singleShot
As proposed https://dev.vatsim-germany.org/issues/483
This commit is contained in:
committed by
Mathew Sutcliffe
parent
a9a6fbc4c0
commit
805ebb109b
@@ -16,6 +16,7 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QTimer>
|
||||
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "blackmisc/fileutilities.h"
|
||||
#include "modeldatareader.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QRegularExpression>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user