From 3aabb83ccf16105bb95d706f9a33d64f0e065310 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Wed, 7 Oct 2020 20:18:11 +0200 Subject: [PATCH] BugFix: remove session filename from list or recent files if failed loading. --- SessionCreator.cpp | 8 ++++++-- UserInterfaceManager.cpp | 10 +++++++++- tinyxml2Toolkit.cpp | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/SessionCreator.cpp b/SessionCreator.cpp index 5420bcc..9f43064 100644 --- a/SessionCreator.cpp +++ b/SessionCreator.cpp @@ -27,8 +27,10 @@ std::string SessionCreator::info(const std::string& filename) XMLDocument doc; XMLError eResult = doc.LoadFile(filename.c_str()); - if ( XMLResultError(eResult)) + if ( XMLResultError(eResult)) { + Log::Warning("%s could not be openned.", filename.c_str()); return ret; + } XMLElement *header = doc.FirstChildElement(APP_NAME); if (header != nullptr && header->Attribute("date") != 0) { @@ -50,8 +52,10 @@ SessionCreator::SessionCreator(): SessionLoader(nullptr) void SessionCreator::load(const std::string& filename) { XMLError eResult = xmlDoc_.LoadFile(filename.c_str()); - if ( XMLResultError(eResult)) + if ( XMLResultError(eResult)){ + Log::Warning("%s could not be openned.", filename.c_str()); return; + } XMLElement *header = xmlDoc_.FirstChildElement(APP_NAME); if (header == nullptr) { diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 95021b3..e4b5899 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -2406,7 +2406,15 @@ void Navigator::RenderMainPannel() } else { file_info = SessionCreator::info(sessionfilename); - file_selected = it; + if (file_info.empty()) { + // failed : remove from recent + if ( selection_session_mode == 0) { + Settings::application.recentSessions.filenames.remove(sessionfilename); + selection_session_mode_changed = true; + } + } + else + file_selected = it; } } if (ImGui::IsItemHovered()) { diff --git a/tinyxml2Toolkit.cpp b/tinyxml2Toolkit.cpp index 8e1b39a..192b719 100644 --- a/tinyxml2Toolkit.cpp +++ b/tinyxml2Toolkit.cpp @@ -221,7 +221,7 @@ bool tinyxml2::XMLResultError(int result) XMLError xmlresult = (XMLError) result; if ( xmlresult != XML_SUCCESS) { - Log::Warning("XML error %i: %s", result, tinyxml2::XMLDocument::ErrorIDToName(xmlresult)); + Log::Info("XML error %i: %s", result, tinyxml2::XMLDocument::ErrorIDToName(xmlresult)); return true; } return false;