From f74379c751255666cb5fc9b98639cceb252b5fee Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jan 2016 17:05:35 +0100 Subject: [PATCH] Avoid duplicate wxEVT_UPDATE_UI for popup menus Don't call wxMenu::UpdateUI() explicitly in wxMSW, wxGTK and wxOSX code before showing the popup menu as it is also called when any menu is opened from port-independent wxFrameBase wxEVT_MENU_OPEN handler, resulting in two events being generated. But also don't send the events from wxFrameBase handler only to the frame itself, by explicitly passing "source" argument to wxMenu::UpdateUI(), as this prevented the event from being sent to the window popping up the menu. By just omitting this parameter we ensure that this event is sent to the right window. Closes #17352 (but notice that there are still duplicate events under OS X, see #17354). --- src/common/framecmn.cpp | 3 +-- src/gtk/window.cpp | 2 -- src/msw/window.cpp | 2 -- src/osx/window_osx.cpp | 2 -- 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index b8d2e454cf..d4ad7d58dd 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -631,8 +631,7 @@ void wxFrameBase::DoMenuUpdates(wxMenu* menu) { if (menu) { - wxEvtHandler* source = GetEventHandler(); - menu->UpdateUI(source); + menu->UpdateUI(); } else { diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 519efa7ed2..e85cc90c77 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4685,8 +4685,6 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) { wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") ); - menu->UpdateUI(); - wxPoint pos; gpointer userdata; GtkMenuPositionFunc posfunc; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 58d8a6d2cd..8337da6091 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2099,8 +2099,6 @@ static void wxYieldForCommandsOnly() bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y) { - menu->UpdateUI(); - wxPoint pt; if ( x == wxDefaultCoord && y == wxDefaultCoord ) { diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index e707143be3..67a96cce70 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -910,8 +910,6 @@ bool wxWindowMac::SetCursor(const wxCursor& cursor) bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y) { #ifndef __WXUNIVERSAL__ - menu->UpdateUI(); - if ( x == wxDefaultCoord && y == wxDefaultCoord ) { wxPoint mouse = wxGetMousePosition();