[Spice-devel] [PATCH spice-gtk 3/5] dbus: remove priv->dbus_conn

Marc-André Lureau marcandre.lureau at gmail.com
Fri Feb 7 04:35:15 PST 2014


On Fri, Feb 7, 2014 at 10:42 AM, Christophe Fergeau <cfergeau at redhat.com> wrote:
> On Thu, Feb 06, 2014 at 01:55:53PM +0100, Marc-André Lureau wrote:
>> From: Marc-André Lureau <marcandre.lureau at redhat.com>
>>
>> It's only needed once, and it is better to group with rest of dbus-glib
>> code.
>
> Patch looks good, any idea if conn should be dbus_g_connection_unref()
> after use?

Not according to API doc, tutorial, and code I could find around.
Anyway that wouldn't be a huge issue if it leaked somehow.

> ACK.
>
> Christophe
>
>> ---
>>  gtk/desktop-integration.c | 18 ++++++------------
>>  1 file changed, 6 insertions(+), 12 deletions(-)
>>
>> diff --git a/gtk/desktop-integration.c b/gtk/desktop-integration.c
>> index dd63b17..06712d9 100644
>> --- a/gtk/desktop-integration.c
>> +++ b/gtk/desktop-integration.c
>> @@ -42,7 +42,6 @@
>>
>>  struct _SpiceDesktopIntegrationPrivate {
>>  #ifdef USE_DBUS_GLIB
>> -    DBusGConnection *dbus_conn;
>>      DBusGProxy *gnome_session_proxy;
>>      guint gnome_automount_inhibit_cookie;
>>  #else
>> @@ -73,18 +72,21 @@ static gboolean gnome_integration_init(SpiceDesktopIntegration *self)
>>  {
>>      SpiceDesktopIntegrationPrivate *priv = self->priv;
>>      GError *error = NULL;
>> +    DBusGConnection *conn;
>>
>> -    if (!priv->dbus_conn)
>> -        return FALSE;
>> +    conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
>> +    if (!conn)
>> +        goto end;
>>
>>      /* We use for_name_owner, to resolve the name now, as we may not be
>>         running under gnome-session manager at all! */
>>      priv->gnome_session_proxy = dbus_g_proxy_new_for_name_owner(
>> -                                            priv->dbus_conn,
>> +                                            conn,
>>                                              "org.gnome.SessionManager",
>>                                              "/org/gnome/SessionManager",
>>                                              "org.gnome.SessionManager",
>>                                              &error);
>> +end:
>>      if (error) {
>>          g_debug("Could not create org.gnome.SessionManager dbus proxy: %s",
>>                  error->message);
>> @@ -155,19 +157,11 @@ static void gnome_integration_dispose(SpiceDesktopIntegration *self)
>>  static void spice_desktop_integration_init(SpiceDesktopIntegration *self)
>>  {
>>      SpiceDesktopIntegrationPrivate *priv;
>> -#ifdef USE_DBUS_GLIB
>> -    GError *error = NULL;
>> -#endif
>>
>>      priv = SPICE_DESKTOP_INTEGRATION_GET_PRIVATE(self);
>>      self->priv = priv;
>>
>>  #ifdef USE_DBUS_GLIB
>> -    priv->dbus_conn = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
>> -    if (!priv->dbus_conn) {
>> -       g_warning("Error connecting to session dbus: %s", error->message);
>> -       g_clear_error(&error);
>> -    }
>>      if (!gnome_integration_init(self))
>>  #endif
>>         g_warning("Warning no automount-inhibiting implementation available");
>> --
>> 1.8.4.2
>>
>> _______________________________________________
>> Spice-devel mailing list
>> Spice-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/spice-devel



-- 
Marc-André Lureau


More information about the Spice-devel mailing list