]> git.saurik.com Git - wxWidgets.git/commitdiff
hack to fix crash when creating a DC for a widgetless window
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 17 Feb 2000 08:47:12 +0000 (08:47 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 17 Feb 2000 08:47:12 +0000 (08:47 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6105 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/dcclient.cpp
src/gtk1/dcclient.cpp

index c4b314a5b8d2045e224aedd969071b6706710d61..4a06916eefb9a867f0ee4ba41700c52bf7b1fca5 100644 (file)
@@ -126,6 +126,15 @@ wxWindowDC::wxWindowDC( wxWindow *window )
 
     GtkWidget *widget = window->m_wxwindow;
 
+    // some controls don't have m_wxwindow - like wxStaticBox, but the user
+    // code should still be able to create wxClientDCs for them, so we will
+    // use the parent window here then
+    if ( !widget )
+    {
+        window = window->GetParent();
+        widget = window->m_wxwindow;
+    }
+
     wxASSERT_MSG( widget, wxT("DC needs a widget") );
 
     GtkPizza *pizza = GTK_PIZZA( widget );
@@ -140,10 +149,7 @@ wxWindowDC::wxWindowDC( wxWindow *window )
          return;
     }
 
-    if (window->m_wxwindow)
-        m_cmap = gtk_widget_get_colormap( window->m_wxwindow );
-    else
-        m_cmap = gtk_widget_get_colormap( window->m_widget );
+    m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget );
 
     SetUpDC();
 
index c4b314a5b8d2045e224aedd969071b6706710d61..4a06916eefb9a867f0ee4ba41700c52bf7b1fca5 100644 (file)
@@ -126,6 +126,15 @@ wxWindowDC::wxWindowDC( wxWindow *window )
 
     GtkWidget *widget = window->m_wxwindow;
 
+    // some controls don't have m_wxwindow - like wxStaticBox, but the user
+    // code should still be able to create wxClientDCs for them, so we will
+    // use the parent window here then
+    if ( !widget )
+    {
+        window = window->GetParent();
+        widget = window->m_wxwindow;
+    }
+
     wxASSERT_MSG( widget, wxT("DC needs a widget") );
 
     GtkPizza *pizza = GTK_PIZZA( widget );
@@ -140,10 +149,7 @@ wxWindowDC::wxWindowDC( wxWindow *window )
          return;
     }
 
-    if (window->m_wxwindow)
-        m_cmap = gtk_widget_get_colormap( window->m_wxwindow );
-    else
-        m_cmap = gtk_widget_get_colormap( window->m_widget );
+    m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget );
 
     SetUpDC();