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:
@@ -1046,9 +1046,8 @@ public:
|
|||||||
// show popup menu at the given position, generate events for the items
|
// show popup menu at the given position, generate events for the items
|
||||||
// selected in it
|
// selected in it
|
||||||
bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition)
|
bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition)
|
||||||
{ return DoPopupMenu(menu, pos.x, pos.y); }
|
{ return PopupMenu(menu, pos.x, pos.y); }
|
||||||
bool PopupMenu(wxMenu *menu, int x, int y)
|
bool PopupMenu(wxMenu *menu, int x, int y);
|
||||||
{ return DoPopupMenu(menu, x, y); }
|
|
||||||
|
|
||||||
// simply return the id of the selected item or wxID_NONE without
|
// simply return the id of the selected item or wxID_NONE without
|
||||||
// generating any events
|
// generating any events
|
||||||
|
@@ -85,6 +85,11 @@
|
|||||||
// Windows List
|
// Windows List
|
||||||
WXDLLIMPEXP_DATA_CORE(wxWindowList) wxTopLevelWindows;
|
WXDLLIMPEXP_DATA_CORE(wxWindowList) wxTopLevelWindows;
|
||||||
|
|
||||||
|
// globals
|
||||||
|
#if wxUSE_MENUS_NATIVE
|
||||||
|
wxMenu *wxCurrentPopupMenu = NULL;
|
||||||
|
#endif // wxUSE_MENUS_NATIVE
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// static data
|
// static data
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -317,6 +322,11 @@ wxWindowBase::~wxWindowBase()
|
|||||||
// we weren't a dialog class
|
// we weren't a dialog class
|
||||||
wxTopLevelWindows.DeleteObject((wxWindow*)this);
|
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") );
|
wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
|
||||||
|
|
||||||
// notify the parent about this window destruction
|
// notify the parent about this window destruction
|
||||||
@@ -2245,6 +2255,17 @@ void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
|
|||||||
|
|
||||||
#if wxUSE_MENUS
|
#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
|
// this is used to pass the id of the selected item from the menu event handler
|
||||||
// to the main function itself
|
// to the main function itself
|
||||||
//
|
//
|
||||||
|
@@ -179,10 +179,6 @@
|
|||||||
// global variables
|
// global variables
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#if wxUSE_MENUS_NATIVE
|
|
||||||
wxMenu *wxCurrentPopupMenu = NULL;
|
|
||||||
#endif // wxUSE_MENUS_NATIVE
|
|
||||||
|
|
||||||
#ifdef __WXWINCE__
|
#ifdef __WXWINCE__
|
||||||
extern wxChar *wxCanvasClassName;
|
extern wxChar *wxCanvasClassName;
|
||||||
#else
|
#else
|
||||||
@@ -2219,7 +2215,6 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y)
|
|||||||
point.x = x;
|
point.x = x;
|
||||||
point.y = y;
|
point.y = y;
|
||||||
::ClientToScreen(hWnd, &point);
|
::ClientToScreen(hWnd, &point);
|
||||||
wxCurrentPopupMenu = menu;
|
|
||||||
#if defined(__WXWINCE__)
|
#if defined(__WXWINCE__)
|
||||||
static const UINT flags = 0;
|
static const UINT flags = 0;
|
||||||
#else // !__WXWINCE__
|
#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
|
// for example) and so we do need to process the event immediately
|
||||||
wxYieldForCommandsOnly();
|
wxYieldForCommandsOnly();
|
||||||
|
|
||||||
wxCurrentPopupMenu = NULL;
|
|
||||||
|
|
||||||
menu->SetInvokingWindow(NULL);
|
menu->SetInvokingWindow(NULL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -1804,7 +1804,6 @@ bool wxWindowOS2::DoPopupMenu( wxMenu* pMenu, int nX, int nY )
|
|||||||
DoGetSize(0,&nHeight);
|
DoGetSize(0,&nHeight);
|
||||||
nY = nHeight - nY;
|
nY = nHeight - nY;
|
||||||
}
|
}
|
||||||
wxCurrentPopupMenu = pMenu;
|
|
||||||
|
|
||||||
::WinPopupMenu( hWndParent
|
::WinPopupMenu( hWndParent
|
||||||
,hWndOwner
|
,hWndOwner
|
||||||
@@ -1825,7 +1824,6 @@ bool wxWindowOS2::DoPopupMenu( wxMenu* pMenu, int nX, int nY )
|
|||||||
::WinDispatchMsg(vHabmain, (PQMSG)&vMsg);
|
::WinDispatchMsg(vHabmain, (PQMSG)&vMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCurrentPopupMenu = NULL;
|
|
||||||
pMenu->SetInvokingWindow(NULL);
|
pMenu->SetInvokingWindow(NULL);
|
||||||
return true;
|
return true;
|
||||||
} // end of wxWindowOS2::DoPopupMenu
|
} // end of wxWindowOS2::DoPopupMenu
|
||||||
|
@@ -83,10 +83,6 @@
|
|||||||
// global variables
|
// global variables
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#if wxUSE_MENUS_NATIVE
|
|
||||||
wxMenu *wxCurrentPopupMenu = NULL;
|
|
||||||
#endif // wxUSE_MENUS_NATIVE
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// private functions
|
// private functions
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user