fix: View provider not correctly saving its state to a project file
This commit is contained in:
parent
2fd17f97b6
commit
d1a59f8c1b
@ -101,8 +101,28 @@ namespace hex::plugin::builtin {
|
||||
return m_provider->getDataDescription();
|
||||
}
|
||||
|
||||
void loadSettings(const nlohmann::json &settings) override { hex::unused(settings); }
|
||||
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings) const override { return settings; }
|
||||
void loadSettings(const nlohmann::json &settings) override {
|
||||
auto id = settings.at("id").get<u64>();
|
||||
m_startAddress = settings.at("start_address").get<u64>();
|
||||
m_size = settings.at("size").get<size_t>();
|
||||
|
||||
const auto &providers = ImHexApi::Provider::getProviders();
|
||||
auto provider = std::ranges::find_if(providers, [id](const prv::Provider *provider) {
|
||||
return provider->getID() == id;
|
||||
});
|
||||
|
||||
if (provider == providers.end())
|
||||
return;
|
||||
|
||||
m_provider = *provider;
|
||||
}
|
||||
|
||||
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings) const override {
|
||||
settings["id"] = m_provider->getID();
|
||||
settings["start_address"] = m_startAddress;
|
||||
settings["size"] = m_size;
|
||||
return settings;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getTypeName() const override {
|
||||
return "hex.builtin.provider.view";
|
||||
|
@ -223,7 +223,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
if (m_writable) {
|
||||
if (m_fileSize < MaxMemoryFileSize && !m_writable) {
|
||||
if (m_fileSize < MaxMemoryFileSize) {
|
||||
m_data = m_file.readVectorAtomic(0x00, m_fileSize);
|
||||
if (!m_data.empty()) {
|
||||
m_changeTracker = wolv::io::ChangeTracker(m_file);
|
||||
|
Loading…
Reference in New Issue
Block a user