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:
Vadim Zeitlin
2007-12-22 16:29:38 +00:00
parent 66a9201df8
commit eeb0bee1d3
5 changed files with 23 additions and 16 deletions

View File

@@ -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
//