From 060daebe17e13e1772a5ab0e43ecaaa06de40250 Mon Sep 17 00:00:00 2001 From: William JCM Date: Mon, 21 Nov 2022 19:09:18 +0100 Subject: [PATCH] SaveTool: improve reliability. --- src/SaveTool/SaveTool_FileWatcher.cpp | 8 +++++++- src/SaveTool/SaveTool_ProfileManager.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/SaveTool/SaveTool_FileWatcher.cpp b/src/SaveTool/SaveTool_FileWatcher.cpp index 3387740..a8bf0a8 100644 --- a/src/SaveTool/SaveTool_FileWatcher.cpp +++ b/src/SaveTool/SaveTool_FileWatcher.cpp @@ -14,10 +14,12 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include #include #include #include +#include #include #include @@ -98,7 +100,11 @@ void SaveTool::fileUpdateEvent(SDL_Event& event) { if(is_current_profile) { _currentProfile = nullptr; _uiState = UiState::ProfileManager; - _profileManager->refreshProfiles(); + if(!_profileManager->refreshProfiles()) { + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", + _profileManager->lastError().data(), window()); + exit(EXIT_FAILURE); + } } else if(is_unit) { if(!_currentMass || _currentMass != &(_massManager->hangar(index))) { diff --git a/src/SaveTool/SaveTool_ProfileManager.cpp b/src/SaveTool/SaveTool_ProfileManager.cpp index 08a037d..50a5c85 100644 --- a/src/SaveTool/SaveTool_ProfileManager.cpp +++ b/src/SaveTool/SaveTool_ProfileManager.cpp @@ -52,7 +52,8 @@ void SaveTool::drawProfileManager() { ImGui::TableSetColumnIndex(1); if(ImGui::SmallButton("Refresh")) { if(!_profileManager->refreshProfiles()) { - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error in ProfileManager", _profileManager->lastError().data(), window()); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", + _profileManager->lastError().data(), window()); exit(EXIT_FAILURE); } } @@ -159,7 +160,11 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID { if(!_profileManager->restoreBackup(backup_index)) { _queue.addToast(Toast::Type::Error, _profileManager->lastError()); } - _profileManager->refreshProfiles(); + if(!_profileManager->refreshProfiles()) { + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", + _profileManager->lastError().data(), window()); + exit(EXIT_FAILURE); + } ImGui::CloseCurrentPopup(); } ImGui::SameLine();