← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~bratsche/appmenu-gtk/toplevel-destroyed-fix into lp:appmenu-gtk

 

Cody Russell has proposed merging lp:~bratsche/appmenu-gtk/toplevel-destroyed-fix into lp:appmenu-gtk.

Requested reviews:
  Canonical Desktop Experience Team (canonical-dx-team)


This fixes some errors we're getting from Valgrind: http://paste.ubuntu.com/491148/
-- 
https://code.launchpad.net/~bratsche/appmenu-gtk/toplevel-destroyed-fix/+merge/35017
Your team ayatana-commits is subscribed to branch lp:appmenu-gtk.
=== modified file 'src/bridge.c'
--- src/bridge.c	2010-09-08 21:21:43 +0000
+++ src/bridge.c	2010-09-09 18:26:48 +0000
@@ -290,11 +290,14 @@
 {
   AppWindowContext *context = (AppWindowContext *)user_data;
 
-  free_context_contents (context);
-
-  context->bridge->priv->windows = g_list_remove (context->bridge->priv->windows, context);
-
-  g_free (context);
+  if (context)
+    {
+      free_context_contents (context);
+
+      context->bridge->priv->windows = g_list_remove (context->bridge->priv->windows, context);
+
+      g_free (context);
+    }
 }
 
 static void
@@ -1111,12 +1114,25 @@
       recurse.count    = 0;
     }
 
-  context->window = toplevel;
-
-  g_signal_connect (toplevel,
-                    "destroy",
-                    G_CALLBACK (toplevel_destroyed),
-                    context);
+  if (context->window)
+    {
+      if (context->window != toplevel)
+        {
+          g_signal_handlers_disconnect_by_func (context->window,
+                                                G_CALLBACK (toplevel_destroyed),
+                                                context);
+        }
+    }
+
+  if (context->window != toplevel)
+    {
+      context->window = toplevel;
+
+      g_signal_connect (toplevel,
+                        "destroy",
+                        G_CALLBACK (toplevel_destroyed),
+                        context);
+    }
 
   if (!context->path)
     context->path = g_strdup_printf ("/org/ayatana/menu/%X", (guint)xid);


Follow ups