Ticket #15387 (closed defect: fixed)
wxWindow starting an infinate event loop
|Reported by:||Chuddah||Owned by:|
|Keywords:||gtk popup menu event loop||Cc:|
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.