Skip to content

Commit

Permalink
fix: File changed popup showing up when saving memory mapped file
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Mar 15, 2024
1 parent 3897245 commit 0f45044
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace hex::plugin::builtin {
wolv::io::ChangeTracker m_changeTracker;
std::vector<u8> m_data;
bool m_loadedIntoMemory = false;
bool m_ignoreNextChangeEvent = false;

std::optional<struct stat> m_fileStats;

Expand Down
6 changes: 6 additions & 0 deletions plugins/builtin/source/content/providers/file_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace hex::plugin::builtin {

void FileProvider::save() {
if (m_loadedIntoMemory) {
m_ignoreNextChangeEvent = true;
m_file.open();
m_file.writeVectorAtomic(0x00, m_data);
m_file.setSize(m_data.size());
Expand Down Expand Up @@ -333,6 +334,11 @@ namespace hex::plugin::builtin {
}

void FileProvider::handleFileChange() {
if (m_ignoreNextChangeEvent) {
m_ignoreNextChangeEvent = false;
return;
}

ui::PopupQuestion::open("hex.builtin.provider.file.reload_changes"_lang, [this] {
this->close();
(void)this->open();
Expand Down

0 comments on commit 0f45044

Please sign in to comment.