From e61b9760d62616e5de6b29c401cdae825438b380 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 14 Dec 2014 17:47:48 +0000 Subject: [PATCH] Fixed crash when sorting after applying settings. It occurred because the settings weren't getting updated with the determined game path, so LOOT was trying to scan an invalid path. The settings now get updated correctly, though initialising a game doesn't update the settings' path in the UI, unless LOOT is restarted. --- src/gui/app.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/app.cpp b/src/gui/app.cpp index 20f7b1e2..62ea8422 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -242,6 +242,8 @@ namespace loot { _currentGame = SelectGame(_settings, _games, cmdLineGame); BOOST_LOG_TRIVIAL(debug) << "Initialising game-specific settings."; _games[_currentGame].Init(true); + // Update game path in settings object. + _settings["games"] = _games; } catch (loot::error &e) { if (e.code() == loot::error::no_game_detected) { @@ -279,8 +281,8 @@ namespace loot { newGameFolders.insert(game.FolderName()); } - // Remove deleted games. As the current game is stored using its index, + // Remove deleted games. As the current game is stored using its index, // removing an earlier game may invalidate it. for (auto it = _games.begin(); it != _games.end();) { if (newGameFolders.find(it->FolderName()) == newGameFolders.end()) { @@ -294,6 +296,11 @@ namespace loot { else ++it; } + + // Re-initialise the current game in case the game path setting was changed. + _games[_currentGame].Init(true); + // Update game path in settings object. + _settings["games"] = _games; } void LootState::ChangeGame(const std::string& newGameFolder) { @@ -305,6 +312,8 @@ namespace loot { _currentGame = std::distance(_games.begin(), it); _games[_currentGame].Init(true); + // Update game path in settings object. + _settings["games"] = _games; BOOST_LOG_TRIVIAL(debug) << "New game is " << _games[_currentGame].Name(); }