From 6de0a414a52c3e13c33fc26b0a8a1b24fca44936 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 26 Apr 2010 14:19:10 +0000 Subject: [PATCH] Don't set invoking window recursively in wxGTK wxWindow::PopupMenu(). Setting the invoking window for all submenus is unnecessary as wxMenu::GetWindow() recurses upwards anyhow and results in assert failures after recent menu code changes. Simply don't do this. OTOH do reset the invoking window to NULL after the menu is dismissed to avoid storing a dangling pointer in the menu. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64142 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index d2f0b65..3bd97fb 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3970,23 +3970,6 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style) #if wxUSE_MENUS_NATIVE -static void SetInvokingWindow( wxMenu *menu, wxWindow* win ) -{ - menu->SetInvokingWindow( win ); - - wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); - while (node) - { - wxMenuItem *menuitem = node->GetData(); - if (menuitem->IsSubMenu()) - { - SetInvokingWindow( menuitem->GetSubMenu(), win ); - } - - node = node->GetNext(); - } -} - extern "C" { static void wxPopupMenuPositionCallback( GtkMenu *menu, @@ -4015,7 +3998,7 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) wxCHECK_MSG( menu != NULL, false, wxT("invalid popup-menu") ); - SetInvokingWindow( menu, this ); + menu->SetInvokingWindow( this ); menu->UpdateUI(); @@ -4051,6 +4034,8 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) gtk_main_iteration(); } + menu->SetInvokingWindow( NULL ); + return true; } -- 2.7.4