Author: miguel
Date: 2007-06-09 01:25:44 -0400 (Sat, 09 Jun 2007)
New Revision: 79030

Modified:
   trunk/moon/src/runtime.cpp
Log:
Be more paranoid, in particular, catch whether the drawing area is destroyed, 
and if so, clear our field pointing to it, to avoid a double destroy later

Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp  2007-06-09 04:22:14 UTC (rev 79029)
+++ trunk/moon/src/runtime.cpp  2007-06-09 05:25:44 UTC (rev 79030)
@@ -784,22 +784,29 @@
 void 
 surface_destroy (Surface *s)
 {
-       if (s->toplevel)
+       if (s->toplevel){
                base_unref (s->toplevel);
+               s->toplevel = NULL;
+       }
 
        cairo_destroy (s->cairo_buffer);
        if (s->cairo_xlib)
                cairo_destroy (s->cairo_xlib);
+       s->cairo_xlib = NULL;
+       s->cairo_buffer = NULL;
 
        if (s->pixmap != NULL)
                gdk_pixmap_unref (s->pixmap);
-       
+       s->pixmap = NULL;
        cairo_surface_destroy (s->cairo_buffer_surface);
        if (s->xlib_surface)
                cairo_surface_destroy (s->xlib_surface);
+       s->cairo_buffer_surface = NULL;
 
-       gtk_widget_destroy (s->drawing_area);
-
+       if (s->drawing_area != NULL){
+               gtk_widget_destroy (s->drawing_area);
+               s->drawing_area = NULL;
+       }
        // TODO: add everything
        delete s;
 }
@@ -902,6 +909,14 @@
        return new Canvas ();
 }
 
+void 
+clear_drawing_area (GtkObject *obj, gpointer data)
+{
+       Surface *s = (Surface *) data;
+
+       s->drawing_area = NULL;
+}
+
 Surface *
 surface_new (int width, int height)
 {
@@ -929,6 +944,9 @@
        gtk_signal_connect (GTK_OBJECT (s->drawing_area), "unrealize",
                            G_CALLBACK (unrealized_callback), s);
 
+       gtk_signal_connect (GTK_OBJECT (s->drawing_area), "destroy",
+                           G_CALLBACK (clear_drawing_area), s);
+
        return s;
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to