fix(gui): use imscope.child in render_heavy_text for exception safety
ROOT CAUSE: render_heavy_text (called per comms panel entry) had manual begin_child/end_child pairs. If anything inside the child (especially markdown_helper.render) raised, end_child was skipped. The child window was left open, corrupting the imGui state. The corruption cascaded through tab_item.end_tab_item -> tab_bar.end_tab_bar -> window.end, triggering 'Must call EndChild() and not End()!' assertion. FIX: Convert the inner begin_child/end_child pair to imscope.child so the end_child is automatically called by Python's with statement, even on exception. Also convert prior_scroll to imscope.child for consistency. TESTS: - Existing test_comms_no_extraneous_pop.py: push/pop balance check - Updated test_prior_session_no_clipping.py to match new imscope.child signature - 28/28 broad regression pass
This commit is contained in:
+10
-15
@@ -3589,9 +3589,8 @@ def render_prior_session_view(app: App) -> None:
|
||||
imgui.text_colored(vec4(200, 180, 100), f"({len(app.prior_disc_entries)} entries)")
|
||||
imgui.separator()
|
||||
avail = imgui.get_content_region_avail()
|
||||
with imscope.child("prior_scroll", size_x=avail.x, size_y=avail.y):
|
||||
clipper = imgui.ListClipper(); clipper.begin(len(app.prior_disc_entries))
|
||||
while clipper.step():
|
||||
with imscope.child("prior_scroll", imgui.ImVec2(avail.x, avail.y), imgui.WindowFlags_.horizontal_scrollbar):
|
||||
clipper = imgui.ListClipper(); clipper.begin(len(app.prior_disc_entries))
|
||||
for idx in range(clipper.display_start, clipper.display_end):
|
||||
entry = app.prior_disc_entries[idx];
|
||||
with imscope.id(f"prior_disc_{idx}"):
|
||||
@@ -4641,19 +4640,15 @@ def render_heavy_text(app: App, label: str, content: str, id_suffix: str = "") -
|
||||
ctx_id = f"{label}_{id_suffix}"
|
||||
is_md = label in ('message', 'text', 'content', 'system')
|
||||
with imscope.indent():
|
||||
if is_md:
|
||||
imgui.begin_child(f"heavy_text_child_{label}_{id_suffix}", imgui.ImVec2(0, 300), True, imgui.WindowFlags_.always_vertical_scrollbar)
|
||||
markdown_helper.render(content, context_id=ctx_id)
|
||||
imgui.end_child()
|
||||
else:
|
||||
imgui.begin_child(f"heavy_text_child_{label}_{id_suffix}", imgui.ImVec2(0, 200), True, imgui.WindowFlags_.always_vertical_scrollbar)
|
||||
if app.ui_word_wrap:
|
||||
with imscope.text_wrap(imgui.get_content_region_avail().x):
|
||||
imgui.text(content)
|
||||
with imscope.child(f"heavy_text_child_{label}_{id_suffix}", imgui.ImVec2(0, 300), imgui.WindowFlags_.always_vertical_scrollbar):
|
||||
if is_md:
|
||||
markdown_helper.render(content, context_id=ctx_id)
|
||||
else:
|
||||
imgui.text(content)
|
||||
imgui.end_child()
|
||||
|
||||
if app.ui_word_wrap:
|
||||
with imscope.text_wrap(imgui.get_content_region_avail().x):
|
||||
imgui.text(content)
|
||||
else:
|
||||
imgui.text(content)
|
||||
|
||||
|
||||
#endregion: Misc Tools
|
||||
|
||||
Reference in New Issue
Block a user