fix: Saving and loading projects not working correctly

This commit is contained in:
WerWolv 2022-09-22 09:05:09 +02:00
parent 55bd2c6da6
commit e34703ea5a
5 changed files with 20 additions and 5 deletions

View File

@ -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);

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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);
}
});
}

View File

@ -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;