mirror of https://github.com/WerWolv/ImHex
Merge 931a8b359f into 62732de227
This commit is contained in:
commit
3d7236f6f2
|
|
@ -64,6 +64,7 @@ namespace hex::plugin::builtin {
|
|||
void convertToDirectAccess();
|
||||
|
||||
private:
|
||||
void fileChangedCallback();
|
||||
void handleFileChange();
|
||||
|
||||
bool open(bool memoryMapped);
|
||||
|
|
|
|||
|
|
@ -237,7 +237,8 @@ namespace hex::plugin::builtin {
|
|||
void registerMenuItems();
|
||||
void registerHandlers();
|
||||
|
||||
void handleFileChange(prv::Provider *provider);
|
||||
void fileChangedCallback(prv::Provider *provider, const std::fs::path &path);
|
||||
void handleFileChange(prv::Provider *provider, const std::fs::path &path);
|
||||
|
||||
void openPatternFile(bool trackFile);
|
||||
void savePatternToCurrentFile(bool trackFile);
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ namespace hex::plugin::builtin {
|
|||
m_data = m_file.readVectorAtomic(0x00, m_fileSize);
|
||||
if (!m_data.empty()) {
|
||||
m_changeTracker = wolv::io::ChangeTracker(m_file);
|
||||
m_changeTracker.startTracking([this]{ this->handleFileChange(); });
|
||||
m_changeTracker.startTracking([this]{ this->fileChangedCallback(); });
|
||||
m_file.close();
|
||||
m_loadedIntoMemory = true;
|
||||
}
|
||||
|
|
@ -364,6 +364,14 @@ namespace hex::plugin::builtin {
|
|||
this->open(true);
|
||||
}
|
||||
|
||||
// WARNING: this function is called from the context of a worker thread!
|
||||
void FileProvider::fileChangedCallback() {
|
||||
// Arrange for a call from the UI thread
|
||||
TaskManager::doLater(
|
||||
[this]{this->handleFileChange();}
|
||||
);
|
||||
}
|
||||
|
||||
void FileProvider::handleFileChange() {
|
||||
if (m_ignoreNextChangeEvent) {
|
||||
m_ignoreNextChangeEvent = false;
|
||||
|
|
|
|||
|
|
@ -1613,7 +1613,7 @@ namespace hex::plugin::builtin {
|
|||
m_sourceCode.get(provider) = code;
|
||||
if (trackFile) {
|
||||
m_changeTracker.get(provider) = wolv::io::ChangeTracker(file);
|
||||
m_changeTracker.get(provider).startTracking([this, provider]{ this->handleFileChange(provider); });
|
||||
m_changeTracker.get(provider).startTracking([this, provider, path]{ this->fileChangedCallback(provider, path); });
|
||||
}
|
||||
m_textHighlighter.m_needsToUpdateColors = false;
|
||||
TaskManager::createBackgroundTask("hex.builtin.task.parsing_pattern", [this, code, provider](auto&) { this->parsePattern(code, provider); });
|
||||
|
|
@ -2534,7 +2534,15 @@ namespace hex::plugin::builtin {
|
|||
});
|
||||
}
|
||||
|
||||
void ViewPatternEditor::handleFileChange(prv::Provider *provider) {
|
||||
// WARNING: this function is called from the context of a worker thread!
|
||||
void ViewPatternEditor::fileChangedCallback(prv::Provider *provider, const std::fs::path &path) {
|
||||
// Arrange for a call from the UI thread
|
||||
TaskManager::doLater(
|
||||
[this, provider, path]{this->handleFileChange(provider, path);}
|
||||
);
|
||||
}
|
||||
|
||||
void ViewPatternEditor::handleFileChange(prv::Provider *provider, const std::fs::path &path) {
|
||||
if (m_ignoreNextChangeEvent.get(provider)) {
|
||||
m_ignoreNextChangeEvent.get(provider) = false;
|
||||
return;
|
||||
|
|
@ -2545,9 +2553,10 @@ namespace hex::plugin::builtin {
|
|||
}
|
||||
|
||||
m_changeEventAcknowledgementPending.get(provider) = true;
|
||||
hex::ui::BannerButton::open(ICON_VS_INFO, "hex.builtin.provider.file.reload_changes", ImColor(66, 104, 135), "hex.builtin.provider.file.reload_changes.reload", [this, provider] {
|
||||
m_changeEventAcknowledgementPending.get(provider) = false;
|
||||
hex::ui::BannerButton::open(ICON_VS_INFO, "hex.builtin.provider.file.reload_changes", ImColor(66, 104, 135), "hex.builtin.provider.file.reload_changes.reload", [this, provider, path] {
|
||||
loadPatternFile(path, provider, true);
|
||||
});
|
||||
m_changeEventAcknowledgementPending.get(provider) = false;
|
||||
}
|
||||
|
||||
void ViewPatternEditor::openPatternFile(bool trackFile) {
|
||||
|
|
@ -2617,7 +2626,7 @@ namespace hex::plugin::builtin {
|
|||
|
||||
if (trackFile) {
|
||||
m_changeTracker.get(provider) = wolv::io::ChangeTracker(file);
|
||||
m_changeTracker.get(provider).startTracking([this, provider]{ this->handleFileChange(provider); });
|
||||
m_changeTracker.get(provider).startTracking([this, provider, path]{ this->fileChangedCallback(provider, path); });
|
||||
m_ignoreNextChangeEvent.get(provider) = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue