unset the window as invoking window of wxCurrentPopupMenu (which now exists in all ports and not just wxMSW-based ones) if it being destroyed before the menu itself (modified patch 1837214)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50903 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
66a9201df8
commit
eeb0bee1d3
@ -1046,9 +1046,8 @@ public:
|
||||
// show popup menu at the given position, generate events for the items
|
||||
// selected in it
|
||||
bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition)
|
||||
{ return DoPopupMenu(menu, pos.x, pos.y); }
|
||||
bool PopupMenu(wxMenu *menu, int x, int y)
|
||||
{ return DoPopupMenu(menu, x, y); }
|
||||
{ return PopupMenu(menu, pos.x, pos.y); }
|
||||
bool PopupMenu(wxMenu *menu, int x, int y);
|
||||
|
||||
// simply return the id of the selected item or wxID_NONE without
|
||||
// generating any events
|
||||
|
@ -85,6 +85,11 @@
|
||||
// Windows List
|
||||
WXDLLIMPEXP_DATA_CORE(wxWindowList) wxTopLevelWindows;
|
||||
|
||||
// globals
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
wxMenu *wxCurrentPopupMenu = NULL;
|
||||
#endif // wxUSE_MENUS_NATIVE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// static data
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -317,6 +322,11 @@ wxWindowBase::~wxWindowBase()
|
||||
// we weren't a dialog class
|
||||
wxTopLevelWindows.DeleteObject((wxWindow*)this);
|
||||
|
||||
// The associated popup menu can still be alive, disassociate from it in
|
||||
// this case
|
||||
if ( wxCurrentPopupMenu && wxCurrentPopupMenu->GetInvokingWindow() == this )
|
||||
wxCurrentPopupMenu->SetInvokingWindow(NULL);
|
||||
|
||||
wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
|
||||
|
||||
// notify the parent about this window destruction
|
||||
@ -2245,6 +2255,17 @@ void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
|
||||
|
||||
#if wxUSE_MENUS
|
||||
|
||||
bool wxWindowBase::PopupMenu(wxMenu *menu, int x, int y)
|
||||
{
|
||||
wxCHECK_MSG( menu, false, "can't popup NULL menu" );
|
||||
|
||||
wxCurrentPopupMenu = menu;
|
||||
const bool rc = DoPopupMenu(menu, x, y);
|
||||
wxCurrentPopupMenu = NULL;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
// this is used to pass the id of the selected item from the menu event handler
|
||||
// to the main function itself
|
||||
//
|
||||
|
@ -179,10 +179,6 @@
|
||||
// global variables
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
wxMenu *wxCurrentPopupMenu = NULL;
|
||||
#endif // wxUSE_MENUS_NATIVE
|
||||
|
||||
#ifdef __WXWINCE__
|
||||
extern wxChar *wxCanvasClassName;
|
||||
#else
|
||||
@ -2219,7 +2215,6 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y)
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
::ClientToScreen(hWnd, &point);
|
||||
wxCurrentPopupMenu = menu;
|
||||
#if defined(__WXWINCE__)
|
||||
static const UINT flags = 0;
|
||||
#else // !__WXWINCE__
|
||||
@ -2248,8 +2243,6 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y)
|
||||
// for example) and so we do need to process the event immediately
|
||||
wxYieldForCommandsOnly();
|
||||
|
||||
wxCurrentPopupMenu = NULL;
|
||||
|
||||
menu->SetInvokingWindow(NULL);
|
||||
|
||||
return true;
|
||||
|
@ -1804,7 +1804,6 @@ bool wxWindowOS2::DoPopupMenu( wxMenu* pMenu, int nX, int nY )
|
||||
DoGetSize(0,&nHeight);
|
||||
nY = nHeight - nY;
|
||||
}
|
||||
wxCurrentPopupMenu = pMenu;
|
||||
|
||||
::WinPopupMenu( hWndParent
|
||||
,hWndOwner
|
||||
@ -1825,7 +1824,6 @@ bool wxWindowOS2::DoPopupMenu( wxMenu* pMenu, int nX, int nY )
|
||||
::WinDispatchMsg(vHabmain, (PQMSG)&vMsg);
|
||||
}
|
||||
|
||||
wxCurrentPopupMenu = NULL;
|
||||
pMenu->SetInvokingWindow(NULL);
|
||||
return true;
|
||||
} // end of wxWindowOS2::DoPopupMenu
|
||||
|
@ -83,10 +83,6 @@
|
||||
// global variables
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
wxMenu *wxCurrentPopupMenu = NULL;
|
||||
#endif // wxUSE_MENUS_NATIVE
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// private functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user