gapplication: don't rely on cmdline being finalized immediately
authorCosimo Cecchi <cosimoc@gnome.org>
Fri, 13 Sep 2013 18:38:47 +0000 (11:38 -0700)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 17 Oct 2013 03:06:13 +0000 (23:06 -0400)
commitc5748328bee08e322997cc4703c372f6866a1693
treeee0a0d1a5a47a8be137378c53f1edbb9e43dc2f9
parentbe2656f13952dd22d348ff5e3f43240700cdef5a
gapplication: don't rely on cmdline being finalized immediately

The GApplicationCommandLine DBus implementation currently calls
g_dbus_method_invocation_return_value() in its finalize() implementation
only, relying on the object being destroyed after g_object_unref() is
called on it inside g_application_impl_method_call().

While this is usually fine for C applications, when overriding the
command_line vfunc from language bindings, the binding might add extra
references to the object, which might not be released immediately - e.g.
because they're garbage collected, or possibly even leaked. The same
scenario could happen in a C application that decides to keep a
reference to the passed-in GApplicationCommandLine object.

To ensure the CommandLine DBus method always gets a reply after the
invocation of command_line in the primary instance, explicitly send the
message back before dropping our reference to the object.

https://bugzilla.gnome.org/show_bug.cgi?id=708042
gio/gapplicationimpl-dbus.c