From 9776c56faa47deb057b61a1796b3674553837c64 Mon Sep 17 00:00:00 2001 From: Automatic Release Builder Date: Sun, 25 Oct 2020 18:26:00 +0000 Subject: [PATCH] Fix a crash (race condition) closing the launcher When local aircraft scanning is slow, we can end up clearing the locale while a scan is in progress, which crashes. Ensure we abandon any in-progress scan when closing the launcher. Sentry-Id: FLIGHTGEAR-CH --- src/GUI/LocalAircraftCache.cxx | 5 +++++ src/GUI/LocalAircraftCache.hxx | 1 + src/GUI/QtLauncher.cxx | 24 ++++++++++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/GUI/LocalAircraftCache.cxx b/src/GUI/LocalAircraftCache.cxx index 1918cae07..5ac8771cc 100644 --- a/src/GUI/LocalAircraftCache.cxx +++ b/src/GUI/LocalAircraftCache.cxx @@ -578,6 +578,11 @@ LocalAircraftCache* LocalAircraftCache::instance() return static_cacheInstance.get(); } +void LocalAircraftCache::reset() +{ + static_cacheInstance.reset(); +} + LocalAircraftCache::LocalAircraftCache() : d(new AircraftCachePrivate) { diff --git a/src/GUI/LocalAircraftCache.hxx b/src/GUI/LocalAircraftCache.hxx index b7a73e9b8..ee63303bb 100644 --- a/src/GUI/LocalAircraftCache.hxx +++ b/src/GUI/LocalAircraftCache.hxx @@ -110,6 +110,7 @@ public: ~LocalAircraftCache(); static LocalAircraftCache* instance(); + static void reset(); void setPaths(QStringList paths); diff --git a/src/GUI/QtLauncher.cxx b/src/GUI/QtLauncher.cxx index 672e94442..5c64022d8 100644 --- a/src/GUI/QtLauncher.cxx +++ b/src/GUI/QtLauncher.cxx @@ -53,13 +53,14 @@ #include #include -#include
-#include
-#include -#include -#include -#include #include +#include +#include
+#include
+#include
+#include +#include +#include #include
@@ -68,10 +69,11 @@ #include #include -#include "LauncherMainWindow.hxx" #include "LaunchConfig.hxx" -#include "UnitsModel.hxx" +#include "LauncherMainWindow.hxx" +#include "LocalAircraftCache.hxx" #include "PathListModel.hxx" +#include "UnitsModel.hxx" using namespace flightgear; using namespace simgear::pkg; @@ -500,6 +502,10 @@ bool runLauncherDialog() return false; // quit } + // avoid a race-y crash on the locale, if a scan thread is + // still running: this reset will cancel any running scan + LocalAircraftCache::reset(); + // don't set scenery paths twice globals->clear_fg_scenery(); globals->get_locale()->clear(); @@ -533,6 +539,8 @@ static const char* static_lockFileDialog_Info = LockFileDialogResult showLockFileDialog() { + flightgear::addSentryBreadcrumb("showing lock-file dialog", "info"); + QString title = qApp->translate("LockFileDialog", static_lockFileDialog_Title); QString text = qApp->translate("LockFileDialog", static_lockFileDialog_Text); QString infoText = qApp->translate("LockFileDialog", static_lockFileDialog_Info);