← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~bratsche/appmenu-gtk/five-is-a-crowd into lp:appmenu-gtk

 

Cody Russell has proposed merging lp:~bratsche/appmenu-gtk/five-is-a-crowd into lp:appmenu-gtk.

Requested reviews:
  Canonical Desktop Experience Team (canonical-dx-team)
Related bugs:
  #628983 Nautilus: menu items not working or triggering wrong functions
  https://bugs.launchpad.net/bugs/628983

-- 
https://code.launchpad.net/~bratsche/appmenu-gtk/five-is-a-crowd/+merge/34918
Your team ayatana-commits is subscribed to branch lp:appmenu-gtk.
=== modified file 'src/bridge.c'
--- src/bridge.c	2010-09-01 14:12:20 +0000
+++ src/bridge.c	2010-09-08 20:59:13 +0000
@@ -237,6 +237,33 @@
 }
 
 static void
+free_context_contents (AppWindowContext *context)
+{
+  if (context->path != NULL)
+    {
+      g_free (context->path);
+      context->path = NULL;
+    }
+
+  if (context->root != NULL)
+    {
+      g_object_unref (context->root);
+      context->root = NULL;
+    }
+
+  if (context->server != NULL)
+    {
+      g_object_unref (context->server);
+      context->server = NULL;
+    }
+
+  if (context->lookup)
+    {
+      g_hash_table_unref (context->lookup);
+    }
+}
+
+static void
 app_menu_bridge_finalize (GObject *object)
 {
   AppMenuBridge *bridge = APP_MENU_BRIDGE (object);
@@ -246,28 +273,7 @@
     {
       AppWindowContext *context = tmp->data;
 
-      if (context->path != NULL)
-        {
-          g_free (context->path);
-          context->path = NULL;
-        }
-
-      if (context->root != NULL)
-        {
-          g_object_unref (context->root);
-          context->root = NULL;
-        }
-
-      if (context->server != NULL)
-        {
-          g_object_unref (context->server);
-          context->server = NULL;
-        }
-
-      if (context->lookup)
-        {
-          g_hash_table_unref (context->lookup);
-        }
+      free_context_contents (context);
 
       g_free (context);
     }
@@ -279,6 +285,19 @@
 }
 
 static void
+toplevel_destroyed (GtkWidget *widget,
+                    gpointer   user_data)
+{
+  AppWindowContext *context = (AppWindowContext *)user_data;
+
+  free_context_contents (context);
+
+  context->bridge->priv->windows = g_list_remove (context->bridge->priv->windows, context);
+
+  g_free (context);
+}
+
+static void
 app_menu_bridge_class_init (AppMenuBridgeClass *class)
 {
   UbuntuMenuProxyClass *proxy_class;
@@ -1097,6 +1116,11 @@
 
   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