1
0
Fork 0

Fix for abandoned cache rebuild dialog

Sentry-Id: FLIGHTGEAR-75G
Sentry-Id: FLIGHTGEAR-860
Sentry-Id: FLIGHTGEAR-BR2
This commit is contained in:
James Turner 2021-06-11 12:56:23 +01:00
parent e23bf8d7d2
commit 6232fd7978

View file

@ -103,7 +103,7 @@ static std::initializer_list<ProgressLabel> progressStrings = {
{NavDataCache::REBUILD_POIS, QT_TRANSLATE_NOOP("initNavCache","Loading point-of-interest data")} {NavDataCache::REBUILD_POIS, QT_TRANSLATE_NOOP("initNavCache","Loading point-of-interest data")}
}; };
void initNavCache() bool initNavCache()
{ {
const char* baseLabelKey = QT_TRANSLATE_NOOP("initNavCache", "Initialising navigation data, this may take several minutes"); const char* baseLabelKey = QT_TRANSLATE_NOOP("initNavCache", "Initialising navigation data, this may take several minutes");
QString baseLabel= qApp->translate("initNavCache", baseLabelKey); QString baseLabel= qApp->translate("initNavCache", baseLabelKey);
@ -127,10 +127,12 @@ void initNavCache()
QTimer updateTimer; QTimer updateTimer;
updateTimer.setInterval(500); updateTimer.setInterval(500);
bool rebuildIsDone = false;
QObject::connect(&updateTimer, &QTimer::timeout, [&waitForRebuild]() { QObject::connect(&updateTimer, &QTimer::timeout, [&waitForRebuild, &rebuildIsDone]() {
if (!NavDataCache::isAnotherProcessRebuilding()) { if (!NavDataCache::isAnotherProcessRebuilding()) {
waitForRebuild.done(0); waitForRebuild.done(0);
rebuildIsDone = true;
return; return;
} }
}); });
@ -138,6 +140,12 @@ void initNavCache()
updateTimer.start(); // timer won't actually run until we process events updateTimer.start(); // timer won't actually run until we process events
waitForRebuild.exec(); waitForRebuild.exec();
updateTimer.stop(); updateTimer.stop();
if (!rebuildIsDone) {
flightgear::addSentryBreadcrumb("Launcher wait on other process nav-cache rebuild abandoned by user", "info");
return false;
}
addSentryBreadcrumb("Launcher: done waiting for other process NavCache rebuild dialog", "info"); addSentryBreadcrumb("Launcher: done waiting for other process NavCache rebuild dialog", "info");
} }
@ -156,10 +164,13 @@ void initNavCache()
QTimer updateTimer; QTimer updateTimer;
updateTimer.setInterval(100); updateTimer.setInterval(100);
QObject::connect(&updateTimer, &QTimer::timeout, [&cache, &rebuildProgress, &baseLabel]() { bool didComplete = false;
QObject::connect(&updateTimer, &QTimer::timeout, [&cache, &rebuildProgress, &baseLabel, &didComplete]() {
auto phase = cache->rebuild(); auto phase = cache->rebuild();
if (phase == NavDataCache::REBUILD_DONE) { if (phase == NavDataCache::REBUILD_DONE) {
rebuildProgress.done(0); rebuildProgress.done(0);
didComplete = true;
return; return;
} }
@ -180,12 +191,20 @@ void initNavCache()
rebuildProgress.setMaximum(100); rebuildProgress.setMaximum(100);
} }
}); });
updateTimer.start(); // timer won't actually run until we process events updateTimer.start(); // timer won't actually run until we process events
rebuildProgress.exec(); rebuildProgress.exec();
updateTimer.stop(); updateTimer.stop();
if (!didComplete) {
flightgear::addSentryBreadcrumb("Launcher nav-cache rebuild abandoned by user", "info");
return false;
}
flightgear::addSentryBreadcrumb("Launcher nav-cache rebuild complete", "info"); flightgear::addSentryBreadcrumb("Launcher nav-cache rebuild complete", "info");
} }
return true;
} }
class NaturalEarthDataLoaderThread : public QThread class NaturalEarthDataLoaderThread : public QThread
@ -591,7 +610,10 @@ bool runLauncherDialog()
// startup the nav-cache now. This pre-empts normal startup of // startup the nav-cache now. This pre-empts normal startup of
// the cache, but no harm done. (Providing scenery paths are consistent) // the cache, but no harm done. (Providing scenery paths are consistent)
initNavCache(); bool ok = initNavCache();
if (!ok) {
return false;
}
auto options = flightgear::Options::sharedInstance(); auto options = flightgear::Options::sharedInstance();
if (options->isOptionSet("download-dir")) { if (options->isOptionSet("download-dir")) {