Opened 5 years ago

Closed 5 years ago

#15387 closed defect (fixed)

wxWindow starting an infinate event loop

Reported by: Chuddah Owned by:
Priority: high Milestone: TNG
Component: wxGTK Version: stable-latest
Keywords: gtk popup menu event loop Cc:
Blocked By: Blocking:
Patch: yes


wxWindow::DoPopupMenu calls gtk_menu_popup()

The loop in wxWindow::DoPopupMenu will continue until menu->m_popupShown == false. This flag is set to false in src/gtk/menu.cpp in menu_hide. This is attached as a callback to the menu hide.

This gtk call (gtk_menu_popup) may fail without realizing the menu and without adding the menu grab to the 'grab list'. When this fails the menu_hide callback will never be executed leaving the m_popupShown flag set to true.

gtk_menu_popup fails in my case as GTK_MENU_SHELL(xgrab_shell)->have_xgrab == false.
Although I dont fully understand this 'have_xgrab' flag wx should not hang because the menu failed to be realized.

The fix (attached patch) checks to verify that the menu has been activated before entering into this potentially infinite loop.

This is a difficult bug to reproduce and had to rely on gdb to halt my program in order to give me enough time to get another user action (clicking elsewhere in the application) processed.

An alternative fix:
The m_popupShown seems to me to be a duplicate flag of the menu_shell->active flag.
It may make sense to just use the menu_shell->active flag as the condition in the loop in wxWindow::DoPoupMenu() although I'm not to certain if this will lead to further problems.


Attachments (1)

window.patch download (337 bytes) - added by Chuddah 5 years ago.

Download all attachments as: .zip

Change History (2)

Changed 5 years ago by Chuddah


comment:1 Changed 5 years ago by PC

  • Resolution set to fixed
  • Status changed from new to closed

(In [74624]) prevent infinite loop if gtk_menu_popup() fails, fixes #15387

Note: See TracTickets for help on using tickets.