Skip to content

Commit

Permalink
TestEngine: MenuAction() requires an update on status if not up to date.
Browse files Browse the repository at this point in the history
Amend b417578. Generally this aims to support what f11facb did, but I don't have repro/details on said bug.
  • Loading branch information
ocornut committed Oct 2, 2024
1 parent b417578 commit 44538c4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions imgui_test_engine/imgui_te_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit 44538c4

Please sign in to comment.