← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/indicator-appmenu/dont-just-remove into lp:indicator-appmenu

 

Ted Gould has proposed merging lp:~ted/indicator-appmenu/dont-just-remove into lp:indicator-appmenu.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)
Related bugs:
  #714531 unity-panel-service consuming very high cpu time
  https://bugs.launchpad.net/bugs/714531

For more details, see:
https://code.launchpad.net/~ted/indicator-appmenu/dont-just-remove/+merge/48809

Using the destroy() function instead of just removing from the hashtable as it handles more details of switching windows.  Then we have to unref as the destroy function does not.
-- 
https://code.launchpad.net/~ted/indicator-appmenu/dont-just-remove/+merge/48809
Your team ayatana-commits is subscribed to branch lp:indicator-appmenu.
=== modified file 'src/indicator-appmenu.c'
--- src/indicator-appmenu.c	2011-02-03 16:10:19 +0000
+++ src/indicator-appmenu.c	2011-02-07 17:17:39 +0000
@@ -203,6 +203,8 @@
 static void dbg_bus_get_cb                                           (GObject * object,
                                                                       GAsyncResult * res,
                                                                       gpointer user_data);
+static void menus_destroyed                                          (GObject * menus,
+                                                                      gpointer user_data);
 
 /* Unique error codes for debug interface */
 enum {
@@ -780,12 +782,24 @@
 	BamfWindow * window = BAMF_WINDOW(view);
 	guint32 xid = bamf_window_get_xid(window);
 
+	/* See if it's in our list of desktop windows, if
+	   so remove it from that list. */
 	if (bamf_window_get_window_type(window) == BAMF_WINDOW_DESKTOP) {
 		g_hash_table_remove(iapp->desktop_windows, GUINT_TO_POINTER(xid));
 	}
-	else {
-		g_debug("Window removed for window: %d", xid);
-		g_hash_table_remove(iapp->apps, GUINT_TO_POINTER(xid));
+
+	/* Now let's see if we've got a WM object for it then
+	   we need to mark it as destroyed and unreference to
+	   actually destroy it. */
+	gpointer wm = g_hash_table_lookup(iapp->apps, GUINT_TO_POINTER(xid));
+	if (wm != NULL) {
+		GObject * wmo = G_OBJECT(wm);
+
+		/* Using destroyed so that if the menus are shown
+		   they'll be switch and the current window gets
+		   updated as well. */
+		menus_destroyed(wmo, iapp);
+		g_object_unref(wmo);
 	}
 
 	return;


Follow ups