From 40a85cae282339cf9cb45811f748eedb6560bee4 Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 10 Mar 2020 16:10:55 +0000 Subject: [PATCH] Launcher: fix some warnings, maybe a crash Avoid binding loop warning, and change logic around re-starting the aircraft dirs scan, to hopefully clarify the crash Brendan and others are seeing. --- src/GUI/AddOnsController.cxx | 8 ++++---- src/GUI/LocalAircraftCache.cxx | 10 ++++++++-- src/GUI/QtLauncher.cxx | 2 +- src/GUI/qml/PathListDelegate.qml | 4 +++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/GUI/AddOnsController.cxx b/src/GUI/AddOnsController.cxx index 06c8d2579..6dfb7777d 100644 --- a/src/GUI/AddOnsController.cxx +++ b/src/GUI/AddOnsController.cxx @@ -44,20 +44,20 @@ AddOnsController::AddOnsController(LauncherMainWindow *parent, LaunchConfig* con m_sceneryPaths = new PathListModel(this); connect(m_sceneryPaths, &PathListModel::enabledPathsChanged, [this] () { - m_sceneryPaths->saveToSettings("scenery-paths"); + m_sceneryPaths->saveToSettings("scenery-paths-v2"); flightgear::launcherSetSceneryPaths(); }); - m_sceneryPaths->loadFromSettings("scenery-paths"); + m_sceneryPaths->loadFromSettings("scenery-paths-v2"); m_aircraftPaths = new PathListModel(this); connect(m_aircraftPaths, &PathListModel::enabledPathsChanged, [this] () { - m_aircraftPaths->saveToSettings("aircraft-paths"); + m_aircraftPaths->saveToSettings("aircraft-paths-v2"); auto aircraftCache = LocalAircraftCache::instance(); aircraftCache->setPaths(m_aircraftPaths->enabledPaths()); aircraftCache->scanDirs(); }); - m_aircraftPaths->loadFromSettings("aircraft-paths"); + m_aircraftPaths->loadFromSettings("aircraft-paths-v2"); QSettings settings; int size = settings.beginReadArray("addon-modules"); diff --git a/src/GUI/LocalAircraftCache.cxx b/src/GUI/LocalAircraftCache.cxx index 3290c6194..10e51faed 100644 --- a/src/GUI/LocalAircraftCache.cxx +++ b/src/GUI/LocalAircraftCache.cxx @@ -253,6 +253,7 @@ public: { m_done = true; } + Q_SIGNALS: void addedItems(); @@ -522,10 +523,15 @@ AircraftItemPtr LocalAircraftCache::findItemWithUri(QUrl aircraftUri) const void LocalAircraftCache::abandonCurrentScan() { if (m_scanThread) { + // don't fire onScanFinished when the thread ends + disconnect(m_scanThread.get(), &AircraftScanThread::finished, this, + &LocalAircraftCache::onScanFinished); + m_scanThread->setDone(); - m_scanThread->wait(1000); + if (!m_scanThread->wait(2000)) { + qWarning() << Q_FUNC_INFO << "scan thread failed to terminate"; + } m_scanThread.reset(); - qWarning() << Q_FUNC_INFO << "current scan abandonded"; } } diff --git a/src/GUI/QtLauncher.cxx b/src/GUI/QtLauncher.cxx index cdf36999e..9c9e1b9c5 100644 --- a/src/GUI/QtLauncher.cxx +++ b/src/GUI/QtLauncher.cxx @@ -404,7 +404,7 @@ void launcherSetSceneryPaths() // positions QSettings settings; // append explicit scenery paths - Q_FOREACH(QString path, PathListModel::readEnabledPaths("scenery-paths")) { + Q_FOREACH(QString path, PathListModel::readEnabledPaths("scenery-paths-v2")) { globals->append_fg_scenery(path.toStdString()); } diff --git a/src/GUI/qml/PathListDelegate.qml b/src/GUI/qml/PathListDelegate.qml index 99138b728..f8fd34a36 100644 --- a/src/GUI/qml/PathListDelegate.qml +++ b/src/GUI/qml/PathListDelegate.qml @@ -42,7 +42,9 @@ Item { anchors.left: parent.left height: parent.height onCheckedChanged: { - model.enabled = checked; + if (model.enabled !== checked) { + model.enabled = checked; + } } }