From 302edba692fce2511cd9640aade61ff2e9009cb1 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sun, 22 Jun 2014 17:01:14 +0100 Subject: [PATCH] Exception handling for saving settings. Should fix issue #174. --- src/gui/main.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 66b68efe..d9a0d40b 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -547,14 +547,19 @@ void Launcher::OnClose(wxCloseEvent& event) { _settings["Games"] = _games; //Save settings. - BOOST_LOG_TRIVIAL(debug) << "Saving LOOT settings."; - YAML::Emitter yout; - yout.SetIndent(2); - yout << _settings; + try { + BOOST_LOG_TRIVIAL(debug) << "Saving LOOT settings."; + YAML::Emitter yout; + yout.SetIndent(2); + yout << _settings; - loot::ofstream out(loot::g_path_settings); - out << yout.c_str(); - out.close(); + loot::ofstream out(loot::g_path_settings); + out << yout.c_str(); + out.close(); + } + catch (std::exception &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to save LOOT's settings. Error: " << e.what(); + } Destroy(); }