1
0
mirror of synced 2025-01-18 17:14:13 +01:00

fix: Properly handle multithreading for new pattern console

This commit is contained in:
WerWolv 2023-06-14 06:57:43 +02:00
parent fdb1cace2d
commit 0e5371b298

View File

@ -298,6 +298,14 @@ namespace hex::plugin::builtin {
} }
void ViewPatternEditor::drawConsole(ImVec2 size) { void ViewPatternEditor::drawConsole(ImVec2 size) {
{
std::scoped_lock lock(this->m_logMutex);
if (this->m_consoleEditor.GetTotalLines() == 1 || size_t(this->m_consoleEditor.GetTotalLines()) != this->m_console->size()) {
this->m_consoleEditor.SetTextLines(*this->m_console);
}
}
this->m_consoleEditor.Render("##console", size, true); this->m_consoleEditor.Render("##console", size, true);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetStyle().FramePadding.y + 1_scaled); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetStyle().FramePadding.y + 1_scaled);
} }
@ -913,8 +921,6 @@ namespace hex::plugin::builtin {
this->m_console->emplace_back(line); this->m_console->emplace_back(line);
} }
this->m_consoleEditor.SetTextLines(this->m_console.get());
}); });
ON_SCOPE_EXIT { ON_SCOPE_EXIT {
@ -929,7 +935,6 @@ namespace hex::plugin::builtin {
this->m_console->emplace_back( this->m_console->emplace_back(
hex::format("I: Evaluation took {}", runtime.getLastRunningTime()) hex::format("I: Evaluation took {}", runtime.getLastRunningTime())
); );
this->m_consoleEditor.SetTextLines(this->m_console.get());
}; };