mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
fix: Multiple race conditions with pattern sorting
This commit is contained in:
@@ -251,7 +251,7 @@ namespace hex::plugin::builtin {
|
||||
PerProvider<TextEditor::Coordinates> m_cursorPosition;
|
||||
PerProvider<std::optional<pl::core::err::PatternLanguageError>> m_lastEvaluationError;
|
||||
PerProvider<std::vector<pl::core::err::CompileError>> m_lastCompileError;
|
||||
PerProvider<std::vector<const pl::core::ast::ASTNode*>> m_callStack;
|
||||
PerProvider<const std::vector<std::unique_ptr<pl::core::ast::ASTNode>>*> m_callStack;
|
||||
PerProvider<std::map<std::string, pl::core::Token::Literal>> m_lastEvaluationOutVars;
|
||||
PerProvider<std::map<std::string, PatternVariable>> m_patternVariables;
|
||||
PerProvider<std::map<u64, pl::api::Section>> m_sections;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void registerPatternLanguagePragmas() {
|
||||
|
||||
ContentRegistry::PatternLanguage::addPragma("base_address", [](const pl::PatternLanguage &runtime, const std::string &value) {
|
||||
ContentRegistry::PatternLanguage::addPragma("base_address", [](pl::PatternLanguage &runtime, const std::string &value) {
|
||||
auto baseAddress = strtoull(value.c_str(), nullptr, 0);
|
||||
|
||||
ImHexApi::Provider::get()->setBaseAddress(baseAddress);
|
||||
@@ -27,4 +27,4 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1343,8 +1343,8 @@ namespace hex::plugin::builtin {
|
||||
};
|
||||
|
||||
TextEditor::ErrorMarkers errorMarkers;
|
||||
if (!m_callStack->empty()) {
|
||||
for (const auto &frame : *m_callStack | std::views::reverse) {
|
||||
if (!(*m_callStack)->empty()) {
|
||||
for (const auto &frame : **m_callStack | std::views::reverse) {
|
||||
auto location = frame->getLocation();
|
||||
std::string message;
|
||||
if (location.source->source == pl::api::Source::DefaultSource) {
|
||||
@@ -1806,7 +1806,7 @@ namespace hex::plugin::builtin {
|
||||
if (!m_lastEvaluationResult) {
|
||||
*m_lastEvaluationError = runtime.getEvalError();
|
||||
*m_lastCompileError = runtime.getCompileErrors();
|
||||
*m_callStack = reinterpret_cast<const std::vector<const pl::core::ast::ASTNode *> &>(runtime.getInternals().evaluator->getCallStack());
|
||||
*m_callStack = &runtime.getInternals().evaluator->getCallStack();
|
||||
}
|
||||
|
||||
TaskManager::doLater([code] {
|
||||
|
||||
@@ -130,5 +130,6 @@ namespace hex::ui {
|
||||
std::function<void(const pl::ptrn::Pattern *)> m_hoverCallback = [](const pl::ptrn::Pattern *) { };
|
||||
|
||||
pl::gen::fmt::FormatterArray m_formatters;
|
||||
u64 m_lastRunId = 0;
|
||||
};
|
||||
}
|
||||
@@ -1214,6 +1214,16 @@ namespace hex::ui {
|
||||
}
|
||||
|
||||
void PatternDrawer::draw(const std::vector<std::shared_ptr<pl::ptrn::Pattern>> &patterns, const pl::PatternLanguage *runtime, float height) {
|
||||
if (runtime == nullptr) {
|
||||
this->reset();
|
||||
} else {
|
||||
auto runId = runtime->getRunId();
|
||||
if (runId != m_lastRunId) {
|
||||
this->reset();
|
||||
m_lastRunId = runId;
|
||||
}
|
||||
}
|
||||
|
||||
std::scoped_lock lock(s_resetDrawMutex);
|
||||
|
||||
m_hoverCallback(nullptr);
|
||||
|
||||
Reference in New Issue
Block a user