1
0
mirror of synced 2024-11-12 10:10:53 +01:00

fix: Modified bytes visually reverting back after saving (#1003)

Fix #988

Co-authored-by: Nik <werwolv98@gmail.com>
This commit is contained in:
Thomas 2023-04-01 11:18:03 +02:00 committed by GitHub
parent 24106b860a
commit af18ca011b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

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

View File

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