Return correct invoking window for submenus of a popup menu.

SetInvokingWindow() is only called for the top menu being popped up itself but
the invoking window should also be associated with its submenus.

Modify GetInvokingWindow() to return the parents invoking window for submenus.

This fixes a crash due to returning NULL from wxMenu::GetWindow() in wxMSW
owner-drawn code.

And it also makes redundant some code in wxUniversal wxMenu implementation
which can now simply use GetInvokingWindow() in all cases.

Closes #11957.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64104 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-04-22 11:21:35 +00:00
parent 29c7962a9f
commit e3f5caa223
4 changed files with 39 additions and 62 deletions

View File

@@ -984,12 +984,7 @@ bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_)
wxWindow *wxMenu::GetWindow() const
{
if ( m_invokingWindow != NULL )
return m_invokingWindow;
else if ( GetMenuBar() != NULL)
return GetMenuBar()->GetFrame();
return NULL;
return GetMenuBar() ? GetMenuBar()->GetFrame() : GetInvokingWindow();
}
// ---------------------------------------------------------------------------