From: Vadim Zeitlin Date: Fri, 22 Jun 2007 19:36:02 +0000 (+0000) Subject: don't crash in SetBackgroundStyle() if the window is not realized X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/788f963310416aebe5bad900b29f07ca2f327d21 don't crash in SetBackgroundStyle() if the window is not realized git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46653 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index a0e09becb5..00ad8466f5 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3962,11 +3962,16 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style) if (style == wxBG_STYLE_CUSTOM) { - GdkWindow *window = (GdkWindow*) NULL; - if (m_wxwindow) + GdkWindow *window; + if ( m_wxwindow ) + { window = GTK_PIZZA(m_wxwindow)->bin_window; + } else - window = GetConnectWidget()->window; + { + GtkWidget * const w = GetConnectWidget(); + window = w ? w->window : NULL; + } if (window) { @@ -3979,9 +3984,11 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style) #endif m_needsStyleChange = false; } - else + else // window not realized yet + { // Do in OnIdle, because the window is not yet available m_needsStyleChange = true; + } // Don't apply widget style, or we get a grey background }