ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #02370
[Merge] lp:~ted/indicator-appmenu/bamf-window-refs into lp:indicator-appmenu
Ted Gould has proposed merging lp:~ted/indicator-appmenu/bamf-window-refs into lp:indicator-appmenu.
Requested reviews:
Indicator Applet Developers (indicator-applet-developers)
Jason was concerned that we needed to keep a ref to the window just incase it got destroyed. Now, I can't come up with a scenario that we would have a reference to this window and it got destroyed unless there was a bug in BAMF. Which is precisely why this branch is critically important.
--
https://code.launchpad.net/~ted/indicator-appmenu/bamf-window-refs/+merge/35874
Your team ayatana-commits is subscribed to branch lp:indicator-appmenu.
=== modified file 'src/indicator-appmenu.c'
--- src/indicator-appmenu.c 2010-09-16 18:51:04 +0000
+++ src/indicator-appmenu.c 2010-09-17 20:06:51 +0000
@@ -739,6 +739,31 @@
return count;
}
+/* Checks to see we cared about a window that's going
+ away, so that we can deal with that */
+static void
+window_finalized_is_active (gpointer user_data, GObject * old_window)
+{
+ g_return_if_fail(IS_INDICATOR_APPMENU(user_data));
+ IndicatorAppmenu * iapp = INDICATOR_APPMENU(user_data);
+
+ /* Pointer comparison as we can't really trust any of the
+ pointers to do any dereferencing */
+ if ((gpointer)iapp->active_window != (gpointer)old_window) {
+ /* Ah, no issue, we weren't caring about this one
+ anyway. */
+ return;
+ }
+
+ iapp->active_window = NULL;
+
+ /* We're going to a state where we don't know what the active
+ window is, hopefully BAMF will save us */
+ active_window_changed (iapp->matcher, NULL, NULL, iapp);
+
+ return;
+}
+
/* A helper for switch_default_app that takes care of the
switching of the active window variable */
static void
@@ -748,7 +773,12 @@
return;
}
+ if (iapp->active_window != NULL) {
+ g_object_weak_unref(G_OBJECT(iapp->active_window), window_finalized_is_active, iapp);
+ }
+
iapp->active_window = active_window;
+ g_object_weak_ref(G_OBJECT(active_window), window_finalized_is_active, iapp);
if (iapp->close_item == NULL) {
g_warning("No close item!?!?!");
Follow ups