From 0465215157ff63700b0c28579cbaaca625ae9823 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Sep 2014 16:12:29 +0000 Subject: [PATCH] Avoid calling SetSize() from wxCompositeWindow::Create() under wxGTK. This was unexpected and resulted in a crash in the case of wxDatePickerCtrl. And while this particular crash could be fixed just by checking for the pointers validity in the overridden wxDatePickerCtrl::SetSize(), it seems better to avoid such unexpected calls to SetSize(), especially as they only happen under wxGTK, which calls SetLayoutDirection(wxLayout_Default) from its wxWindow::Create(), and so wouldn't be found by any amount of testing under other platforms. Closes #16589. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77890 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/compositewin.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/wx/compositewin.h b/include/wx/compositewin.h index 9a3536854a..a58d2e7e6c 100644 --- a/include/wx/compositewin.h +++ b/include/wx/compositewin.h @@ -102,7 +102,14 @@ public: // The child layout almost invariably depends on the layout direction, // so redo it when it changes. - this->SetSize(-1, -1, -1, -1, wxSIZE_AUTO | wxSIZE_FORCE); + // + // However avoid doing it when we're called from wxWindow::Create() in + // wxGTK as the derived window is not fully created yet and calling its + // SetSize() may be unexpected. This does mean that any future calls to + // SetLayoutDirection(wxLayout_Default) wouldn't result in a re-layout + // neither, but then we're not supposed to be called with it at all. + if ( dir != wxLayout_Default ) + this->SetSize(-1, -1, -1, -1, wxSIZE_AUTO | wxSIZE_FORCE); } #if wxUSE_TOOLTIPS