diff --git a/lib/libimhex/include/hex/providers/provider.hpp b/lib/libimhex/include/hex/providers/provider.hpp index 82deefaa7..87b452f0e 100644 --- a/lib/libimhex/include/hex/providers/provider.hpp +++ b/lib/libimhex/include/hex/providers/provider.hpp @@ -86,9 +86,8 @@ namespace hex::prv { virtual void drawLoadInterface(); virtual void drawInterface(); - [[nodiscard]] u32 getID() const { - return this->m_id; - } + [[nodiscard]] u32 getID() const; + void setID(u32 id); [[nodiscard]] virtual nlohmann::json storeSettings(nlohmann::json settings = { }) const; virtual void loadSettings(const nlohmann::json &settings); diff --git a/lib/libimhex/source/api/project_file_manager.cpp b/lib/libimhex/source/api/project_file_manager.cpp index 7b43f5c97..5785758cb 100644 --- a/lib/libimhex/source/api/project_file_manager.cpp +++ b/lib/libimhex/source/api/project_file_manager.cpp @@ -36,6 +36,10 @@ namespace hex { return false; } + for (const auto &provider : ImHexApi::Provider::getProviders()) { + ImHexApi::Provider::remove(provider); + } + bool result = true; for (const auto &handler : ProjectFile::getHandlers()) { try { diff --git a/lib/libimhex/source/providers/provider.cpp b/lib/libimhex/source/providers/provider.cpp index fe89932e8..4ab7f8675 100644 --- a/lib/libimhex/source/providers/provider.cpp +++ b/lib/libimhex/source/providers/provider.cpp @@ -288,4 +288,15 @@ namespace hex::prv { return { Region { address, *nextRegionAddress - address }, insideValidRegion }; } + + u32 Provider::getID() const { + return this->m_id; + } + + void Provider::setID(u32 id) { + this->m_id = id; + if (id > s_idCounter) + s_idCounter = id + 1; + } + } diff --git a/plugins/builtin/source/content/main_menu_items.cpp b/plugins/builtin/source/content/main_menu_items.cpp index fe75ee668..65723765c 100644 --- a/plugins/builtin/source/content/main_menu_items.cpp +++ b/plugins/builtin/source/content/main_menu_items.cpp @@ -77,8 +77,8 @@ namespace hex::plugin::builtin { path.replace_extension(".hexproj"); } - if (!ProjectFile::load(path)) { - View::showErrorPopup("hex.builtin.popup.error.project.load"_lang); + if (!ProjectFile::store(path)) { + View::showErrorPopup("hex.builtin.popup.error.project.save"_lang); } }); } diff --git a/plugins/builtin/source/content/providers.cpp b/plugins/builtin/source/content/providers.cpp index aa7a21892..5cd48cb36 100644 --- a/plugins/builtin/source/content/providers.cpp +++ b/plugins/builtin/source/content/providers.cpp @@ -40,6 +40,7 @@ namespace hex::plugin::builtin { continue; } + provider->setID(id); provider->loadSettings(providerSettings["settings"]); if (!provider->open() || !provider->isAvailable() || !provider->isReadable()) success = false;