1
0
Fork 0

Launcher: abandon NautralEarth loading on ‘fly!’

Otherwise we waste time trying to commit loaded data during FG main
startup, which causes races on the NavCache, and is pointless.
This commit is contained in:
James Turner 2020-11-02 14:55:35 +00:00 committed by James Turner
parent 3c1594ead4
commit c63594acec

View file

@ -39,6 +39,7 @@
#include <QProcess> #include <QProcess>
#include <QTranslator> #include <QTranslator>
#include <QMessageBox> #include <QMessageBox>
#include <QPointer>
// Simgear // Simgear
#include <simgear/timing/timestamp.hxx> #include <simgear/timing/timestamp.hxx>
@ -187,6 +188,10 @@ public:
connect(this, &QThread::finished, this, &NaturalEarthDataLoaderThread::onFinished); connect(this, &QThread::finished, this, &NaturalEarthDataLoaderThread::onFinished);
} }
void abandon()
{
m_abandoned = true;
}
protected: protected:
void run() override void run() override
{ {
@ -199,6 +204,9 @@ protected:
private: private:
Q_SLOT void onFinished() Q_SLOT void onFinished()
{ {
if (m_abandoned)
return;
flightgear::PolyLineList::const_iterator begin = m_parsedLines.begin() + m_lineInsertCount; flightgear::PolyLineList::const_iterator begin = m_parsedLines.begin() + m_lineInsertCount;
unsigned int numToAdd = std::min<unsigned int>(1000U, static_cast<unsigned int>(m_parsedLines.size()) - m_lineInsertCount); unsigned int numToAdd = std::min<unsigned int>(1000U, static_cast<unsigned int>(m_parsedLines.size()) - m_lineInsertCount);
flightgear::PolyLineList::const_iterator end = begin + numToAdd; flightgear::PolyLineList::const_iterator end = begin + numToAdd;
@ -228,6 +236,7 @@ private:
flightgear::PolyLineList m_parsedLines; flightgear::PolyLineList m_parsedLines;
unsigned int m_lineInsertCount; unsigned int m_lineInsertCount;
bool m_abandoned = false;
}; };
} // of anonymous namespace } // of anonymous namespace
@ -511,7 +520,7 @@ bool runLauncherDialog()
// will happen as normal // will happen as normal
http->init(); http->init();
NaturalEarthDataLoaderThread* naturalEarthLoader = new NaturalEarthDataLoaderThread; QPointer<NaturalEarthDataLoaderThread> naturalEarthLoader = new NaturalEarthDataLoaderThread;
naturalEarthLoader->start(); naturalEarthLoader->start();
// avoid double Apple menu and other weirdness if both Qt and OSG // avoid double Apple menu and other weirdness if both Qt and OSG
@ -530,6 +539,12 @@ bool runLauncherDialog()
return false; // quit return false; // quit
} }
// avoid crashes / NavCache races if the loader is still running after
// the launcher exits
if (naturalEarthLoader) {
naturalEarthLoader->abandon();
}
// avoid a race-y crash on the locale, if a scan thread is // avoid a race-y crash on the locale, if a scan thread is
// still running: this reset will cancel any running scan // still running: this reset will cancel any running scan
LocalAircraftCache::reset(); LocalAircraftCache::reset();