Test for wxAuiMDIClientWindow being non-NULL before using it.

wxAuiMDIParentFrame::GetActiveChild() may be called before the client window
is created, don't crash in this case but just return NULL.

Closes #14684.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72601 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-10-01 09:55:27 +00:00
parent 77dd7daad2
commit 91ad3a26e3

View File

@@ -244,14 +244,18 @@ bool wxAuiMDIParentFrame::ProcessEvent(wxEvent& event)
wxAuiMDIChildFrame *wxAuiMDIParentFrame::GetActiveChild() const
{
return GetClientWindow()->GetActiveChild();
// We can be called before the client window is created, so check for its
// existence.
wxAuiMDIClientWindow* const client = GetClientWindow();
return client ? client->GetActiveChild() : NULL;
}
void wxAuiMDIParentFrame::SetActiveChild(wxAuiMDIChildFrame* pChildFrame)
{
if (GetClientWindow()->GetActiveChild() != pChildFrame)
wxAuiMDIClientWindow* const client = GetClientWindow();
if (client && client->GetActiveChild() != pChildFrame)
{
GetClientWindow()->SetActiveChild(pChildFrame);
client->SetActiveChild(pChildFrame);
}
}