BugFix: remove session filename from list or recent files if failed

loading.
This commit is contained in:
brunoherbelin
2020-10-07 20:18:11 +02:00
parent 82b755db84
commit 3aabb83ccf
3 changed files with 16 additions and 4 deletions

View File

@@ -27,8 +27,10 @@ std::string SessionCreator::info(const std::string& filename)
XMLDocument doc; XMLDocument doc;
XMLError eResult = doc.LoadFile(filename.c_str()); 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; return ret;
}
XMLElement *header = doc.FirstChildElement(APP_NAME); XMLElement *header = doc.FirstChildElement(APP_NAME);
if (header != nullptr && header->Attribute("date") != 0) { if (header != nullptr && header->Attribute("date") != 0) {
@@ -50,8 +52,10 @@ SessionCreator::SessionCreator(): SessionLoader(nullptr)
void SessionCreator::load(const std::string& filename) void SessionCreator::load(const std::string& filename)
{ {
XMLError eResult = xmlDoc_.LoadFile(filename.c_str()); XMLError eResult = xmlDoc_.LoadFile(filename.c_str());
if ( XMLResultError(eResult)) if ( XMLResultError(eResult)){
Log::Warning("%s could not be openned.", filename.c_str());
return; return;
}
XMLElement *header = xmlDoc_.FirstChildElement(APP_NAME); XMLElement *header = xmlDoc_.FirstChildElement(APP_NAME);
if (header == nullptr) { if (header == nullptr) {

View File

@@ -2406,7 +2406,15 @@ void Navigator::RenderMainPannel()
} }
else { else {
file_info = SessionCreator::info(sessionfilename); 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()) { if (ImGui::IsItemHovered()) {

View File

@@ -221,7 +221,7 @@ bool tinyxml2::XMLResultError(int result)
XMLError xmlresult = (XMLError) result; XMLError xmlresult = (XMLError) result;
if ( xmlresult != XML_SUCCESS) 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 true;
} }
return false; return false;