From 5680b90549dc940772daf3d31c72afd62f28b38f Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 4 May 2023 23:23:44 +0200 Subject: [PATCH] fix: Project files failing to save when no custom encoding is loaded --- lib/libimhex/source/api/project_file_manager.cpp | 12 ++++++++---- .../builtin/source/content/views/view_hex_editor.cpp | 3 +-- plugins/windows/source/content/ui_items.cpp | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/libimhex/source/api/project_file_manager.cpp b/lib/libimhex/source/api/project_file_manager.cpp index 6acb338a1..9e1c51a3c 100644 --- a/lib/libimhex/source/api/project_file_manager.cpp +++ b/lib/libimhex/source/api/project_file_manager.cpp @@ -109,22 +109,26 @@ namespace hex { bool result = true; for (const auto &handler : ProjectFile::getHandlers()) { try { - if (!handler.store(handler.basePath, tar)) + if (!handler.store(handler.basePath, tar) && handler.required) result = false; } catch (std::exception &e) { log::info("{}", e.what()); - result = false; + + if (handler.required) + result = false; } } for (const auto &provider : ImHexApi::Provider::getProviders()) { const auto basePath = std::fs::path(std::to_string(provider->getID())); for (const auto &handler: ProjectFile::getProviderHandlers()) { try { - if (!handler.store(provider, basePath / handler.basePath, tar)) + if (!handler.store(provider, basePath / handler.basePath, tar) && handler.required) result = false; } catch (std::exception &e) { log::info("{}", e.what()); - result = false; + + if (handler.required) + result = false; } } } diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index 139f32951..bbff972c5 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -900,10 +900,9 @@ namespace hex::plugin::builtin { .store = [this](prv::Provider *, const std::fs::path &basePath, Tar &tar) { if (const auto &encoding = this->m_hexEditor.getCustomEncoding(); encoding.has_value()) { tar.writeString(basePath, encoding->getTableContent()); - return true; } - return false; + return true; } }); } diff --git a/plugins/windows/source/content/ui_items.cpp b/plugins/windows/source/content/ui_items.cpp index ea41888e4..a821682e4 100644 --- a/plugins/windows/source/content/ui_items.cpp +++ b/plugins/windows/source/content/ui_items.cpp @@ -101,7 +101,7 @@ namespace hex::plugin::windows { } auto totalMem = memInfo.ullTotalPhys; - auto usedMem = pmc.PrivateUsage; + auto usedMem = pmc.WorkingSetSize; ImGui::TextFormatted(ICON_FA_MICROCHIP " {0} / {1}", hex::toByteString(usedMem), hex::toByteString(totalMem)); });