From 830c06655b226cfe9fe55d57da8c948d1744107c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 26 May 2013 13:14:43 +0000 Subject: [PATCH] Ensure that detached menus don't keep focus grab in wxGTK. A widget being hidden must remove its focus grab with GTK+, otherwise GTK+ would continue sending all input messages to it but fail to process them because the widget is not realized any more, resulting in a complete freeze of the entire program. Do it when detaching menus from menubar and menubar from the frame to fix just such a problem in case SetMenuBar() was called while the previous menubar was opened. Closes #15221. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/menu.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 09fecd8a14..686761a6be 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -152,6 +152,18 @@ wxMenuBar::wxMenuBar() namespace { +// This should be called when detaching menus to ensure that they don't keep +// focus grab, because if they do, they continue getting all GTK+ messages +// which they can't process any more in their (soon to be) unrealized state. +void +EnsureNoGrab(GtkWidget* widget) +{ +#if !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 + gtk_widget_hide(widget); + gtk_grab_remove(widget); +#endif // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 +} + void DetachFromFrame(wxMenu* menu, wxFrame* frame) { @@ -173,6 +185,8 @@ DetachFromFrame(wxMenu* menu, wxFrame* frame) DetachFromFrame(menuitem->GetSubMenu(), frame); node = node->GetNext(); } + + EnsureNoGrab(menu->m_menu); } void @@ -260,6 +274,8 @@ void wxMenuBar::Detach() node = node->GetNext(); } + EnsureNoGrab(m_widget); + wxMenuBarBase::Detach(); } -- 2.45.2