Author: miguel
Date: 2007-06-23 15:55:19 -0400 (Sat, 23 Jun 2007)
New Revision: 80603

Modified:
   trunk/moon/src/runtime.cpp
Log:
2007-06-23  Miguel de Icaza  <[EMAIL PROTECTED]>

        * runtime.cpp: Since unrealize does not seem to be called when our
        widget is destroyed by Mozilla, we need to cleanup on destroy the
        tick event.   This takes care of one of the plugin crashers.

        There are still others that I have to find out, I added some
        debugging prints for now.



Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp  2007-06-23 19:53:20 UTC (rev 80602)
+++ trunk/moon/src/runtime.cpp  2007-06-23 19:55:19 UTC (rev 80603)
@@ -1269,7 +1269,6 @@
        }
 
        s->cairo = s->cairo_buffer;
-
        TimeManager::Instance()->RemoveHandler ("render", render_surface, s);
 }
 
@@ -1564,6 +1563,16 @@
        }
 }
 
+static void
+surface_drawing_area_destroyed (GtkWidget *widget, gpointer data)
+{
+       Surface *s = (Surface *) data;
+
+       // This is never called, why?
+       printf ("------------------ WE ARE DESTROYED ---------------\n");
+       s->drawing_area = NULL;
+}
+
 Surface *
 surface_new (int width, int height)
 {
@@ -1572,7 +1581,9 @@
        s->drawing_area = gtk_drawing_area_new ();
        gtk_signal_connect (GTK_OBJECT (s->drawing_area), "size_allocate",
                            G_CALLBACK(surface_size_allocate), s);
-                           
+       gtk_signal_connect (GTK_OBJECT (s->drawing_area), "destroy",
+                           G_CALLBACK(surface_drawing_area_destroyed), s);
+
        gtk_widget_add_events (s->drawing_area, 
                               GDK_POINTER_MOTION_MASK |
                               GDK_POINTER_MOTION_HINT_MASK |
@@ -1612,6 +1623,22 @@
 
 Surface::~Surface ()
 {
+       //
+       // This removes one source of problems: the unrealize handler is not
+       // being called when Mozilla destroys our window, so we remove it here.
+       //
+       // This is easy to trigger, open two clocks and try to load a different
+       // page on one of the pages (that keeps the timer ticking, and 
eventually
+       // kills this
+       //
+       // There is still another problem: sometimes we are getting:
+       //     The error was 'RenderBadPicture (invalid Picture parameter)'.
+       //
+       // And I have yet to track what causes this, the stack trace is not 
+       // very useful
+       //
+       TimeManager::Instance()->RemoveHandler ("render", render_surface, this);
+
        if (toplevel) {
                toplevel->unref ();
                toplevel = NULL;
@@ -2414,6 +2441,7 @@
        closure->func = handler;
        closure->data = data;
 
+       printf ("**** Adding handler %s pointing to %p with data %p\n");
        if (events == NULL) {
                g_hash_table_insert (event_hash, g_strdup (event_name), 
g_list_prepend (NULL, closure));
        }
@@ -2426,6 +2454,8 @@
 EventObject::RemoveHandler (char *event_name, EventHandler handler, gpointer 
data)
 {
        gpointer key, value;
+
+       printf ("**** Removing handler %s pointing to %p with data %p\n");
        if (!g_hash_table_lookup_extended (event_hash, event_name,
                                           &key, &value)) {
                return;

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

Reply via email to