From: Vadim Zeitlin Date: Thu, 25 Jul 2013 21:54:53 +0000 (+0000) Subject: Don't crash when creating wxStaticBox in wxGTK. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/94e1ee1b4d4050fa04e3688a21ed0b1693a0b456?ds=inline Don't crash when creating wxStaticBox in wxGTK. Since r74585, wxWindow::SetCanFocus() is called from wxStaticBoxBase ctor, i.e. before the real window is created, and this results in a crash in wxGTK where SetCanFocus() needs a valid widget. Fix this simply by doing nothing in SetCanFocus() if the widget is not created yet as this should result in the same behaviour as before r74585. This doesn't seem like the right thing to do, however, and we should probably remove this call from wxStaticBoxBase ctor and do it in wxStaticBox implementation itself instead. Closes #15358. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74594 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 854937fed3..bedca9fba3 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3376,7 +3376,8 @@ void wxWindowGTK::SetFocus() void wxWindowGTK::SetCanFocus(bool canFocus) { - gtk_widget_set_can_focus(m_widget, canFocus); + if ( m_widget ) + gtk_widget_set_can_focus(m_widget, canFocus); if ( m_wxwindow && (m_widget != m_wxwindow) ) {