Ref T367, info objects are also read, as the files are small and sApp->isInternetAccessible() is not fully reliable (Qt Accessibility bug)

This commit is contained in:
Klaus Basan
2018-09-22 01:10:58 +02:00
parent 7ae7d04548
commit 4dcb2185b4
2 changed files with 18 additions and 27 deletions

View File

@@ -179,6 +179,11 @@ namespace BlackCore
const CDbInfoList infoObjects = CDbInfoList::fromDatabaseJson(res.getJsonArray()); const CDbInfoList infoObjects = CDbInfoList::fromDatabaseJson(res.getJsonArray());
const int n = infoObjects.size(); const int n = infoObjects.size();
// Service URL => DB data
// DB data directory => shared files
const QString urlStr = nwReply->url().toString();
Q_UNUSED(urlStr); // debug only
// this part needs to be synchronized // this part needs to be synchronized
{ {
QWriteLocker wl(&m_lockInfoObjects); QWriteLocker wl(&m_lockInfoObjects);

View File

@@ -1153,22 +1153,14 @@ namespace BlackCore
// start in own thread // start in own thread
m_dbInfoDataReader->start(QThread::LowPriority); m_dbInfoDataReader->start(QThread::LowPriority);
}
// and trigger read
if (sApp->isInternetAccessible())
{
const QPointer<CWebDataServices> myself(this); const QPointer<CWebDataServices> myself(this);
QTimer::singleShot(0, m_dbInfoDataReader, [ = ]() QTimer::singleShot(25, m_dbInfoDataReader, [ = ]()
{ {
if (!myself) { return; } if (!myself || m_shuttingDown) { return; }
m_dbInfoDataReader->read(); m_dbInfoDataReader->read(); // trigger read of info objects
}); });
} }
else
{
CLogMessage(this).warning("No network/internet access, skipping read of info objects");
}
} }
void CWebDataServices::initSharedInfoObjectReaderAndTriggerRead() void CWebDataServices::initSharedInfoObjectReaderAndTriggerRead()
@@ -1180,7 +1172,7 @@ namespace BlackCore
const QPointer<CWebDataServices> myself(this); const QPointer<CWebDataServices> myself(this);
QTimer::singleShot(0, this, [ = ] QTimer::singleShot(0, this, [ = ]
{ {
if (!myself) { return; } if (!myself || m_shuttingDown) { return; }
this->initSharedInfoObjectReaderAndTriggerRead(); this->initSharedInfoObjectReaderAndTriggerRead();
}); });
return; return;
@@ -1203,20 +1195,13 @@ namespace BlackCore
} }
// and trigger read // and trigger read
if (sApp->isInternetAccessible())
{
const QPointer<CWebDataServices> myself(this); const QPointer<CWebDataServices> myself(this);
QTimer::singleShot(0, m_sharedInfoDataReader, [ = ]() QTimer::singleShot(25, m_sharedInfoDataReader, [ = ]()
{ {
if (!myself) { return; } if (!myself || m_shuttingDown) { return; }
m_sharedInfoDataReader->read(); m_sharedInfoDataReader->read();
}); });
} }
else
{
CLogMessage(this).warning("No network/internet access, skipping read of shared data");
}
}
CDatabaseReader *CWebDataServices::getDbReader(CEntityFlags::Entity entity) const CDatabaseReader *CWebDataServices::getDbReader(CEntityFlags::Entity entity) const
{ {
@@ -1357,7 +1342,7 @@ namespace BlackCore
const QPointer<CWebDataServices> myself(this); const QPointer<CWebDataServices> myself(this);
QTimer::singleShot(delayMs, [ = ]() QTimer::singleShot(delayMs, [ = ]()
{ {
if (!myself) { return; } if (!myself || m_shuttingDown) { return; }
this->readInBackground(entities); // deferred this->readInBackground(entities); // deferred
}); });
} }
@@ -1452,7 +1437,7 @@ namespace BlackCore
{ {
// ok, this means we are parsing // ok, this means we are parsing
this->readDeferredInBackground(entities, waitForInfoObjectsMs); this->readDeferredInBackground(entities, waitForInfoObjectsMs);
CLogMessage(this).info("Waiting for objects (%1) for '%2' from '%3'") << info << CEntityFlags::flagToString(entities) << infoReader->getInfoObjectsUrl().toQString(); CLogMessage(this).info("Parsing objects (%1) for '%2' from '%3'") << info << CEntityFlags::flagToString(entities) << infoReader->getInfoObjectsUrl().toQString();
return false; // wait return false; // wait
} }
else else
@@ -1467,6 +1452,7 @@ namespace BlackCore
else else
{ {
// wait for 1st reply // wait for 1st reply
// we call read again in some time
this->readDeferredInBackground(entities, waitForInfoObjectsMs); this->readDeferredInBackground(entities, waitForInfoObjectsMs);
return false; // wait return false; // wait
} }