From e8027adbb6dbceb3c28b5c5d7748fb974372396f Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 28 Jan 2006 12:28:56 +0000 Subject: [PATCH] converting menu ids and safeguarding against missing menu items git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/window.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 7f282379cb..3dc206ee7a 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -1665,15 +1665,19 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y) long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() , y, x, 0) ; if ( HiWord(menuResult) != 0 ) { - MenuCommand id ; - GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ; - wxMenuItem* item = NULL ; + MenuCommand macid; + GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &macid ); + int id = wxMacCommandToId( macid ); + wxMenuItem* item = NULL ; wxMenu* realmenu ; item = menu->FindItem( id, &realmenu ) ; - if (item->IsCheckable()) - item->Check( !item->IsChecked() ) ; + if ( item ) + { + if (item->IsCheckable()) + item->Check( !item->IsChecked() ) ; - menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; + menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; + } } menu->MacAfterDisplay( true ) ; -- 2.45.2