1
0
Fork 0

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
This commit is contained in:
Automatic Release Builder 2020-10-25 18:26:00 +00:00 committed by James Turner
parent df42c6f026
commit 9776c56faa
3 changed files with 22 additions and 8 deletions

View file

@ -578,6 +578,11 @@ LocalAircraftCache* LocalAircraftCache::instance()
return static_cacheInstance.get(); return static_cacheInstance.get();
} }
void LocalAircraftCache::reset()
{
static_cacheInstance.reset();
}
LocalAircraftCache::LocalAircraftCache() : LocalAircraftCache::LocalAircraftCache() :
d(new AircraftCachePrivate) d(new AircraftCachePrivate)
{ {

View file

@ -110,6 +110,7 @@ public:
~LocalAircraftCache(); ~LocalAircraftCache();
static LocalAircraftCache* instance(); static LocalAircraftCache* instance();
static void reset();
void setPaths(QStringList paths); void setPaths(QStringList paths);

View file

@ -53,13 +53,14 @@
#include <simgear/package/Install.hxx> #include <simgear/package/Install.hxx>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Navaids/NavDataCache.hxx>
#include <Navaids/navrecord.hxx>
#include <Navaids/SHPParser.hxx>
#include <Airports/airport.hxx>
#include <Add-ons/AddonManager.hxx> #include <Add-ons/AddonManager.hxx>
#include <Airports/airport.hxx>
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include <Main/sentryIntegration.hxx>
#include <Navaids/NavDataCache.hxx>
#include <Navaids/SHPParser.hxx>
#include <Navaids/navrecord.hxx>
#include <Main/fg_init.hxx> #include <Main/fg_init.hxx>
@ -68,10 +69,11 @@
#include <Network/HTTPClient.hxx> #include <Network/HTTPClient.hxx>
#include <Viewer/WindowBuilder.hxx> #include <Viewer/WindowBuilder.hxx>
#include "LauncherMainWindow.hxx"
#include "LaunchConfig.hxx" #include "LaunchConfig.hxx"
#include "UnitsModel.hxx" #include "LauncherMainWindow.hxx"
#include "LocalAircraftCache.hxx"
#include "PathListModel.hxx" #include "PathListModel.hxx"
#include "UnitsModel.hxx"
using namespace flightgear; using namespace flightgear;
using namespace simgear::pkg; using namespace simgear::pkg;
@ -500,6 +502,10 @@ bool runLauncherDialog()
return false; // quit 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 // don't set scenery paths twice
globals->clear_fg_scenery(); globals->clear_fg_scenery();
globals->get_locale()->clear(); globals->get_locale()->clear();
@ -533,6 +539,8 @@ static const char* static_lockFileDialog_Info =
LockFileDialogResult showLockFileDialog() LockFileDialogResult showLockFileDialog()
{ {
flightgear::addSentryBreadcrumb("showing lock-file dialog", "info");
QString title = qApp->translate("LockFileDialog", static_lockFileDialog_Title); QString title = qApp->translate("LockFileDialog", static_lockFileDialog_Title);
QString text = qApp->translate("LockFileDialog", static_lockFileDialog_Text); QString text = qApp->translate("LockFileDialog", static_lockFileDialog_Text);
QString infoText = qApp->translate("LockFileDialog", static_lockFileDialog_Info); QString infoText = qApp->translate("LockFileDialog", static_lockFileDialog_Info);