feat: Properly save memory provider data

This commit is contained in:
WerWolv
2023-08-06 21:48:08 +02:00
parent e77f138514
commit ba9227c1e0
2 changed files with 19 additions and 4 deletions

View File

@@ -12,8 +12,11 @@
namespace hex::plugin::builtin {
bool MemoryFileProvider::open() {
this->m_data.resize(1);
this->markDirty();
if (this->m_data.empty()) {
this->m_data.resize(1);
this->markDirty();
}
return true;
}
@@ -109,4 +112,16 @@ namespace hex::plugin::builtin {
return { Region::Invalid(), false };
}
void MemoryFileProvider::loadSettings(const nlohmann::json &settings) {
Provider::loadSettings(settings);
this->m_data = settings["data"].get<std::vector<u8>>();
}
[[nodiscard]] nlohmann::json MemoryFileProvider::storeSettings(nlohmann::json settings) const {
settings["data"] = this->m_data;
return Provider::storeSettings(settings);
}
}