]> git.saurik.com Git - wxWidgets.git/commitdiff
don't crash in SetBackgroundStyle() if the window is not realized
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 22 Jun 2007 19:36:02 +0000 (19:36 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 22 Jun 2007 19:36:02 +0000 (19:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46653 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/window.cpp

index a0e09becb59fcbd57624e2e7823f5dfebe639858..00ad8466f5128a5dc7e9fb648f80de3a980f8003 100644 (file)
@@ -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
     }