From 2b8c3f64aca06c69a6468112657bc6b105675925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 6 Dec 2020 12:53:39 +0100 Subject: [PATCH] Only trigger the last loaded map --- src/GUI/gui.cpp | 21 ++++++++++++--------- src/GUI/gui.h | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index 6213dea8..00cfbda8 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -1434,19 +1434,25 @@ void GUI::loadMap() QStringList files = QFileDialog::getOpenFileNames(this, tr("Open map file"), _mapDir, MapList::formats()); QStringList list = files; + MapAction *lastReady = 0; - for (QStringList::Iterator it = list.begin(); it != list.end(); it++) - loadMap(*it); + for (QStringList::Iterator it = list.begin(); it != list.end(); it++) { + MapAction *a = loadMap(*it); + if (a) + lastReady = a; + } if (!list.isEmpty()) _mapDir = QFileInfo(list.first()).path(); + if (lastReady) + lastReady->trigger(); } -bool GUI::loadMap(const QString &fileName) +MapAction *GUI::loadMap(const QString &fileName) { // On OS X fileName may be a directory! if (fileName.isEmpty()) - return false; + return 0; QString error; QList maps = MapList::loadMaps(fileName, error); @@ -1454,7 +1460,7 @@ bool GUI::loadMap(const QString &fileName) error = tr("Error loading map:") + "\n\n" + fileName + "\n\n" + error; QMessageBox::critical(this, APP_NAME, error); - return false; + return 0; } MapAction *lastReady = 0; @@ -1470,10 +1476,7 @@ bool GUI::loadMap(const QString &fileName) connect(a, SIGNAL(loaded()), this, SLOT(mapLoaded())); } - if (lastReady) - lastReady->trigger(); - - return true; + return lastReady; } void GUI::mapLoaded() diff --git a/src/GUI/gui.h b/src/GUI/gui.h index 512ef686..1c38ffac 100644 --- a/src/GUI/gui.h +++ b/src/GUI/gui.h @@ -120,7 +120,7 @@ private: bool openPOIFile(const QString &fileName); bool loadFile(const QString &fileName); - bool loadMap(const QString &fileName); + MapAction *loadMap(const QString &fileName); void updateStatusBarInfo(); void updateWindowTitle(); void updateNavigationActions();