mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 05:51:23 +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 <QRegularExpression>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
@@ -326,14 +327,15 @@ namespace BlackCore
|
|||||||
return (whatToRead & CEntityFlags::AllIcaoAndCountries) == reallyRead;
|
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);
|
bool s = this->readFromJsonFiles(dir, whatToRead);
|
||||||
Q_UNUSED(s);
|
Q_UNUSED(s);
|
||||||
});
|
});
|
||||||
return worker;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CIcaoDataReader::writeToJsonFiles(const QString &dir) const
|
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);
|
bool readFromJsonFiles(const QString &dir, BlackMisc::Network::CEntityFlags::Entity whatToRead = BlackMisc::Network::CEntityFlags::AllIcaoAndCountries);
|
||||||
|
|
||||||
//! Read from static DB data file
|
//! 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
|
//! Write to static DB data file
|
||||||
bool writeToJsonFiles(const QString &dir) const;
|
bool writeToJsonFiles(const QString &dir) const;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "blackmisc/fileutilities.h"
|
#include "blackmisc/fileutilities.h"
|
||||||
#include "modeldatareader.h"
|
#include "modeldatareader.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
@@ -323,14 +324,15 @@ namespace BlackCore
|
|||||||
return (reallyRead & CEntityFlags::DistributorLiveryModel) == whatToRead;
|
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);
|
bool s = this->readFromJsonFiles(dir, whatToRead);
|
||||||
Q_UNUSED(s);
|
Q_UNUSED(s);
|
||||||
});
|
});
|
||||||
return worker;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CModelDataReader::writeToJsonFiles(const QString &dir) const
|
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);
|
bool readFromJsonFiles(const QString &dir, BlackMisc::Network::CEntityFlags::Entity whatToRead = BlackMisc::Network::CEntityFlags::DistributorLiveryModel);
|
||||||
|
|
||||||
//! Read from static DB data file
|
//! 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
|
//! Write to JSON file
|
||||||
bool writeToJsonFiles(const QString &dir) const;
|
bool writeToJsonFiles(const QString &dir) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user