From 7d47c6e14e3a21d90f64775c776624d24c323af3 Mon Sep 17 00:00:00 2001 From: DanS Date: Sat, 18 Jul 2026 13:39:42 -0500 Subject: [PATCH] fix(console): balance colour-toggle push/pop so it stops drawing a red error rect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The accent + text-colour toggle buttons pushed/popped ImGuiCol_Text guarded by a flag the TactileButton flips in between, so a click left the colour stack unbalanced for that frame — and ImGui's error recovery drew a red rectangle around the console window (imgui.cpp:11727). Capture the flag into a local before the button and guard both the push and the pop with it. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/ui/windows/console_tab.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui/windows/console_tab.cpp b/src/ui/windows/console_tab.cpp index 1e3ca75..ca8b9b1 100644 --- a/src/ui/windows/console_tab.cpp +++ b/src/ui/windows/console_tab.cpp @@ -572,12 +572,14 @@ void ConsoleTab::renderToolbar(ConsoleCommandExecutor& exec) ImGui::SameLine(); { float btnSz = ImGui::GetFrameHeight(); + // Capture the flag BEFORE the button can flip it — the push/pop guards must use the SAME value, + // or a click leaves the colour stack unbalanced (ImGui then draws a red error rect on the window). + const bool dim = !s_line_accents_enabled; const char* icon = s_line_accents_enabled ? ICON_MD_FORMAT_COLOR_FILL : ICON_MD_FORMAT_COLOR_RESET; - if (!s_line_accents_enabled) - ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled())); + if (dim) ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled())); if (TactileButton(icon, ImVec2(btnSz, btnSz), Type().iconMed())) s_line_accents_enabled = !s_line_accents_enabled; - if (!s_line_accents_enabled) ImGui::PopStyleColor(); + if (dim) ImGui::PopStyleColor(); if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("console_toggle_accents")); } @@ -585,11 +587,11 @@ void ConsoleTab::renderToolbar(ConsoleCommandExecutor& exec) ImGui::SameLine(); { float btnSz = ImGui::GetFrameHeight(); - if (!s_line_text_color_enabled) - ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled())); + const bool dim = !s_line_text_color_enabled; // capture before the click flips it (balanced push/pop) + if (dim) ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled())); if (TactileButton(ICON_MD_FORMAT_COLOR_TEXT, ImVec2(btnSz, btnSz), Type().iconMed())) s_line_text_color_enabled = !s_line_text_color_enabled; - if (!s_line_text_color_enabled) ImGui::PopStyleColor(); + if (dim) ImGui::PopStyleColor(); if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("console_toggle_text_color")); }