fix: Multiple race conditions with pattern sorting
This commit is contained in:
parent
101c7a36fb
commit
3739bcc40c
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ cmake-build-*/
|
|||||||
build*/
|
build*/
|
||||||
local/
|
local/
|
||||||
venv/
|
venv/
|
||||||
|
.cache/
|
||||||
|
|
||||||
*.mgc
|
*.mgc
|
||||||
*.kdev4
|
*.kdev4
|
||||||
|
@ -32,6 +32,7 @@ include("${IMHEX_BASE_FOLDER}/cmake/ide_helpers.cmake")
|
|||||||
# Basic compiler and cmake configurations
|
# Basic compiler and cmake configurations
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
|
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
include("${IMHEX_BASE_FOLDER}/cmake/build_helpers.cmake")
|
include("${IMHEX_BASE_FOLDER}/cmake/build_helpers.cmake")
|
||||||
|
|
||||||
# Setup project
|
# Setup project
|
||||||
|
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
@ -1 +1 @@
|
|||||||
Subproject commit a210503daf9f906578ec3c31484e489e5980933a
|
Subproject commit 432904c30bc2db346799afe2fa46e0984a49a9e6
|
@ -1322,8 +1322,6 @@ void TextEditor::EnterCharacter(ImWchar aChar, bool aShift) {
|
|||||||
auto coord = GetActualCursorCoordinates();
|
auto coord = GetActualCursorCoordinates();
|
||||||
u.mAddedStart = coord;
|
u.mAddedStart = coord;
|
||||||
|
|
||||||
assert(!mLines.empty());
|
|
||||||
|
|
||||||
if (aChar == '\n') {
|
if (aChar == '\n') {
|
||||||
InsertLine(coord.mLine + 1);
|
InsertLine(coord.mLine + 1);
|
||||||
auto &line = mLines[coord.mLine];
|
auto &line = mLines[coord.mLine];
|
||||||
|
@ -74,7 +74,7 @@ namespace hex {
|
|||||||
&& FcPatternGetString(font, FC_FAMILY, 0, &fullName) != FcResultMatch) {
|
&& FcPatternGetString(font, FC_FAMILY, 0, &fullName) != FcResultMatch) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
registerFont(reinterpret_cast<const char *>(fullName), reinterpret_cast<const char *>(file));
|
registerFont(reinterpret_cast<const char *>(fullName), reinterpret_cast<const char *>(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ namespace hex {
|
|||||||
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
|
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
|
||||||
|
|
||||||
#if defined(GLFW_WAYLAND_APP_ID)
|
#if defined(GLFW_WAYLAND_APP_ID)
|
||||||
glfwWindowHintString(GLFW_WAYLAND_APP_ID, "imhex");
|
glfwWindowHintString(GLFW_WAYLAND_APP_ID, "imhex");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,4 +190,4 @@ namespace hex {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -251,7 +251,7 @@ namespace hex::plugin::builtin {
|
|||||||
PerProvider<TextEditor::Coordinates> m_cursorPosition;
|
PerProvider<TextEditor::Coordinates> m_cursorPosition;
|
||||||
PerProvider<std::optional<pl::core::err::PatternLanguageError>> m_lastEvaluationError;
|
PerProvider<std::optional<pl::core::err::PatternLanguageError>> m_lastEvaluationError;
|
||||||
PerProvider<std::vector<pl::core::err::CompileError>> m_lastCompileError;
|
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, pl::core::Token::Literal>> m_lastEvaluationOutVars;
|
||||||
PerProvider<std::map<std::string, PatternVariable>> m_patternVariables;
|
PerProvider<std::map<std::string, PatternVariable>> m_patternVariables;
|
||||||
PerProvider<std::map<u64, pl::api::Section>> m_sections;
|
PerProvider<std::map<u64, pl::api::Section>> m_sections;
|
||||||
|
@ -9,7 +9,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
void registerPatternLanguagePragmas() {
|
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);
|
auto baseAddress = strtoull(value.c_str(), nullptr, 0);
|
||||||
|
|
||||||
ImHexApi::Provider::get()->setBaseAddress(baseAddress);
|
ImHexApi::Provider::get()->setBaseAddress(baseAddress);
|
||||||
@ -27,4 +27,4 @@ namespace hex::plugin::builtin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1343,8 +1343,8 @@ namespace hex::plugin::builtin {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TextEditor::ErrorMarkers errorMarkers;
|
TextEditor::ErrorMarkers errorMarkers;
|
||||||
if (!m_callStack->empty()) {
|
if (!(*m_callStack)->empty()) {
|
||||||
for (const auto &frame : *m_callStack | std::views::reverse) {
|
for (const auto &frame : **m_callStack | std::views::reverse) {
|
||||||
auto location = frame->getLocation();
|
auto location = frame->getLocation();
|
||||||
std::string message;
|
std::string message;
|
||||||
if (location.source->source == pl::api::Source::DefaultSource) {
|
if (location.source->source == pl::api::Source::DefaultSource) {
|
||||||
@ -1806,7 +1806,7 @@ namespace hex::plugin::builtin {
|
|||||||
if (!m_lastEvaluationResult) {
|
if (!m_lastEvaluationResult) {
|
||||||
*m_lastEvaluationError = runtime.getEvalError();
|
*m_lastEvaluationError = runtime.getEvalError();
|
||||||
*m_lastCompileError = runtime.getCompileErrors();
|
*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] {
|
TaskManager::doLater([code] {
|
||||||
|
@ -130,5 +130,6 @@ namespace hex::ui {
|
|||||||
std::function<void(const pl::ptrn::Pattern *)> m_hoverCallback = [](const pl::ptrn::Pattern *) { };
|
std::function<void(const pl::ptrn::Pattern *)> m_hoverCallback = [](const pl::ptrn::Pattern *) { };
|
||||||
|
|
||||||
pl::gen::fmt::FormatterArray m_formatters;
|
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) {
|
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);
|
std::scoped_lock lock(s_resetDrawMutex);
|
||||||
|
|
||||||
m_hoverCallback(nullptr);
|
m_hoverCallback(nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user