From 91ad3a26e39458e6fcd593165ad0a7aaccbe86a1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 1 Oct 2012 09:55:27 +0000 Subject: [PATCH] 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 --- src/aui/tabmdi.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/aui/tabmdi.cpp b/src/aui/tabmdi.cpp index 13dc090b01..edf19a97be 100644 --- a/src/aui/tabmdi.cpp +++ b/src/aui/tabmdi.cpp @@ -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); } } -- 2.50.0