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:
@@ -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
|
||||
//
|
||||
|
Reference in New Issue
Block a user