Menus are not destroyed when a window is closed with GDbus port

Bug #703769 reported by Chris Coulson
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Application Menu Indicator
Fix Released
Undecided
Chris Coulson
indicator-appmenu (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: indicator-appmenu

Previously, when an application dropped off the bus, indicator-appmenu would catch the NameOwnerChanged signal and properties_destroyed would unref the WindowMenus instance, causing it to be destroyed.

In the GDbus port, each WindowMenus instance connects to the notify::g-name-owner signal.

However, this never actually fires, as it only works for well known bus names (see this code snippet from gdbusproxy.c:async_initable_init_first):

  if (proxy->priv->name != NULL && !g_dbus_is_unique_name (proxy->priv->name))
    {
      proxy->priv->name_owner_changed_subscription_id =
        g_dbus_connection_signal_subscribe (proxy->priv->connection,
                                            "org.freedesktop.DBus", /* name */
                                            "org.freedesktop.DBus", /* interface */
                                            "NameOwnerChanged", /* signal name */
                                            "/org/freedesktop/DBus", /* path */
                                            proxy->priv->name, /* arg0 */
                                            G_DBUS_SIGNAL_FLAGS_NONE,
                                            on_name_owner_changed,
                                            proxy,
                                            NULL);
    }

The side effect of this is that the panel now leaks WindowMenus instances. And if applications reuse XID's, then things get really messy (and Firefox windows always seem to get the same XID, I'm not sure why though...)

Related branches

Changed in indicator-appmenu (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Hmmm, I'm misunderstanding how it used to work, as the destroy signal from DbusGProxy is only fired when the proxy is destroyed, and not when the application disappears off the bus.

This used to work somehow though.

The new code in indicator-appmenu (listening to the notify::g-name-owner signal in window-menus.c) doesn't seem to work anyway though (it's never fired), and appears to be trying to do something different to the code it replaced.

Revision history for this message
Michael Terry (mterry) wrote :

Old DBusGProxys did emit "destroy" when a unique owner died:

"This proxy will only emit the "destroy" signal if the DBusConnection is disconnected, the proxy has no remaining references, or the name is a unique name and its owner disappears. If a well-known name changes owner, the proxy will still be alive."

You're right that notify::g-name-owner does not get emitted for owner changes on unique names though. I missed that here.

Instead of linking and using bamf, I think the better thing to do is to use g_bus_watch_name and friends, which promise to work on unique names. I'll look at that.

Changed in indicator-appmenu:
assignee: nobody → Michael Terry (mterry)
status: New → In Progress
Revision history for this message
Chris Coulson (chrisccoulson) wrote :

I used bamf, because looking for the name going away doesn't handle the case where an application window closes, but the application keeps on running (eg, multiple gedit windows etc....)

Revision history for this message
Michael Terry (mterry) wrote :

Ah, you are 100% right. I dig your branch conceptually now. Thanks for cleaning up my gdbus port.

Changed in indicator-appmenu:
assignee: Michael Terry (mterry) → Chris Coulson (chrisccoulson)
Ted Gould (ted)
Changed in indicator-appmenu:
milestone: none → 0.1.91
status: In Progress → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package indicator-appmenu - 0.1.91-0ubuntu1

---------------
indicator-appmenu (0.1.91-0ubuntu1) natty; urgency=low

  * New upstream release.
    * Using BAMF to watch for window destruction (LP: #703769)
 -- Ted Gould <email address hidden> Thu, 20 Jan 2011 08:49:37 -0600

Changed in indicator-appmenu (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.