]> git.saurik.com Git - wxWidgets.git/commitdiff
Test for wxAuiMDIClientWindow being non-NULL before using it.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 1 Oct 2012 09:55:27 +0000 (09:55 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 1 Oct 2012 09:55:27 +0000 (09:55 +0000)
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

index 13dc090b019940f362714d496f25f92ba82c1208..edf19a97beda95d7b857cb206ec65e9e1c13659f 100644 (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);
     }
 }