patterns: Fixed race condition when evaluating patterns
This commit is contained in:
parent
78cb0a2592
commit
4f08ba3590
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
@ -1 +1 @@
|
||||
Subproject commit 337a45a7684e46ae2c7462f82097af428b7d52d3
|
||||
Subproject commit 72ab71a9166063f4688bc87d55be08ead4f0c1d7
|
@ -21,6 +21,7 @@ namespace hex::plugin::builtin {
|
||||
private:
|
||||
ui::PatternDrawer m_patternDrawer;
|
||||
bool m_shouldReset = false;
|
||||
u64 m_lastRunId = 0;
|
||||
};
|
||||
|
||||
}
|
@ -20,10 +20,6 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
this->m_patternDrawer.setSelectionCallback([](Region region){ ImHexApi::HexEditor::setSelection(region); });
|
||||
|
||||
EventManager::subscribe<EventPatternExecuted>([this](const auto&){
|
||||
this->m_shouldReset = true;
|
||||
});
|
||||
}
|
||||
|
||||
ViewPatternData::~ViewPatternData() {
|
||||
@ -36,11 +32,14 @@ namespace hex::plugin::builtin {
|
||||
if (ImHexApi::Provider::isValid()) {
|
||||
auto &runtime = ContentRegistry::PatternLanguage::getRuntime();
|
||||
if (!runtime.arePatternsValid()) {
|
||||
this->m_shouldReset = true;
|
||||
this->m_patternDrawer.reset();
|
||||
this->m_patternDrawer.draw({});
|
||||
} else {
|
||||
if (TRY_LOCK(ContentRegistry::PatternLanguage::getRuntimeLock())) {
|
||||
if (this->m_shouldReset) {
|
||||
auto runId = runtime.getRunId();
|
||||
if (this->m_shouldReset || this->m_lastRunId != runId) {
|
||||
this->m_lastRunId = runId;
|
||||
this->m_patternDrawer.reset();
|
||||
this->m_shouldReset = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user