From 44538c4a904dcaeac2467f534b7cd4ccf32b87c1 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 2 Oct 2024 18:06:35 +0200 Subject: [PATCH] TestEngine: MenuAction() requires an update on status if not up to date. Amend b417578. Generally this aims to support what f11facb98 did, but I don't have repro/details on said bug. --- imgui_test_engine/imgui_te_context.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/imgui_test_engine/imgui_te_context.cpp b/imgui_test_engine/imgui_te_context.cpp index a6e31ce..5b8e72e 100644 --- a/imgui_test_engine/imgui_te_context.cpp +++ b/imgui_test_engine/imgui_te_context.cpp @@ -3356,10 +3356,17 @@ void ImGuiTestContext::MenuAction(ImGuiTestAction action, ImGuiTestRef ref) depth++; #endif + // Timestamps updated in hooks submitted in ui code. ImGuiTestItemInfo item = ItemInfo(buf.c_str()); IM_CHECK_SILENT(item.ID != 0); - bool has_latest_status = (item.TimestampStatus == UiContext->FrameCount); - if ((item.StatusFlags & ImGuiItemStatusFlags_Opened) == 0 || !has_latest_status) // Open menus can be ignored completely. + if (item.TimestampStatus < UiContext->FrameCount) + { + Yield(); + item = ItemInfo(buf.c_str()); + IM_CHECK_SILENT(item.ID != 0); + } + + if ((item.StatusFlags & ImGuiItemStatusFlags_Opened) == 0) // Open menus can be ignored completely. { // We cannot move diagonally to a menu item because depending on the angle and other items we cross on our path we could close our target menu. // First move horizontally into the menu, then vertically!