1
0
Fork 0

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.
This commit is contained in:
James Turner 2020-03-10 16:10:55 +00:00
parent e2135369ce
commit 40a85cae28
4 changed files with 16 additions and 8 deletions

View file

@ -44,20 +44,20 @@ AddOnsController::AddOnsController(LauncherMainWindow *parent, LaunchConfig* con
m_sceneryPaths = new PathListModel(this); m_sceneryPaths = new PathListModel(this);
connect(m_sceneryPaths, &PathListModel::enabledPathsChanged, [this] () { connect(m_sceneryPaths, &PathListModel::enabledPathsChanged, [this] () {
m_sceneryPaths->saveToSettings("scenery-paths"); m_sceneryPaths->saveToSettings("scenery-paths-v2");
flightgear::launcherSetSceneryPaths(); flightgear::launcherSetSceneryPaths();
}); });
m_sceneryPaths->loadFromSettings("scenery-paths"); m_sceneryPaths->loadFromSettings("scenery-paths-v2");
m_aircraftPaths = new PathListModel(this); m_aircraftPaths = new PathListModel(this);
connect(m_aircraftPaths, &PathListModel::enabledPathsChanged, [this] () { connect(m_aircraftPaths, &PathListModel::enabledPathsChanged, [this] () {
m_aircraftPaths->saveToSettings("aircraft-paths"); m_aircraftPaths->saveToSettings("aircraft-paths-v2");
auto aircraftCache = LocalAircraftCache::instance(); auto aircraftCache = LocalAircraftCache::instance();
aircraftCache->setPaths(m_aircraftPaths->enabledPaths()); aircraftCache->setPaths(m_aircraftPaths->enabledPaths());
aircraftCache->scanDirs(); aircraftCache->scanDirs();
}); });
m_aircraftPaths->loadFromSettings("aircraft-paths"); m_aircraftPaths->loadFromSettings("aircraft-paths-v2");
QSettings settings; QSettings settings;
int size = settings.beginReadArray("addon-modules"); int size = settings.beginReadArray("addon-modules");

View file

@ -253,6 +253,7 @@ public:
{ {
m_done = true; m_done = true;
} }
Q_SIGNALS: Q_SIGNALS:
void addedItems(); void addedItems();
@ -522,10 +523,15 @@ AircraftItemPtr LocalAircraftCache::findItemWithUri(QUrl aircraftUri) const
void LocalAircraftCache::abandonCurrentScan() void LocalAircraftCache::abandonCurrentScan()
{ {
if (m_scanThread) { 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->setDone();
m_scanThread->wait(1000); if (!m_scanThread->wait(2000)) {
qWarning() << Q_FUNC_INFO << "scan thread failed to terminate";
}
m_scanThread.reset(); m_scanThread.reset();
qWarning() << Q_FUNC_INFO << "current scan abandonded";
} }
} }

View file

@ -404,7 +404,7 @@ void launcherSetSceneryPaths()
// positions // positions
QSettings settings; QSettings settings;
// append explicit scenery paths // 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()); globals->append_fg_scenery(path.toStdString());
} }

View file

@ -42,7 +42,9 @@ Item {
anchors.left: parent.left anchors.left: parent.left
height: parent.height height: parent.height
onCheckedChanged: { onCheckedChanged: {
model.enabled = checked; if (model.enabled !== checked) {
model.enabled = checked;
}
} }
} }