fix: Modified bytes visually reverting back after saving (#1003)
Fix #988 Co-authored-by: Nik <werwolv98@gmail.com>
This commit is contained in:
parent
24106b860a
commit
af18ca011b
@ -29,6 +29,11 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void readRaw(u64 offset, void *buffer, size_t size) override;
|
||||
void writeRaw(u64 offset, const void *buffer, size_t size) override;
|
||||
/**
|
||||
* @brief closes the file streams used to read the file.
|
||||
* Need to be called on file write, see https://github.com/WerWolv/ImHex/issues/988
|
||||
*/
|
||||
void invalidateFiles();
|
||||
[[nodiscard]] size_t getActualSize() const override;
|
||||
|
||||
void save() override;
|
||||
|
@ -77,7 +77,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
writeFile.seek(offset);
|
||||
writeFile.writeBuffer(reinterpret_cast<const u8*>(buffer), size);
|
||||
this->m_files.clear();
|
||||
|
||||
this->invalidateFiles();
|
||||
}
|
||||
|
||||
void FileProvider::save() {
|
||||
@ -124,6 +125,13 @@ namespace hex::plugin::builtin {
|
||||
Provider::insert(offset, size);
|
||||
}
|
||||
|
||||
void FileProvider::invalidateFiles() {
|
||||
for(auto & [threadId, file] : this->m_files){
|
||||
file.close();
|
||||
}
|
||||
this->m_files.clear();
|
||||
}
|
||||
|
||||
void FileProvider::remove(u64 offset, size_t size) {
|
||||
auto oldSize = this->getActualSize();
|
||||
this->resize(oldSize + size);
|
||||
|
Loading…
Reference in New Issue
Block a user