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

Christophe Fergeau cfergeau at redhat.com
Fri Feb 7 01:42:17 PST 2014


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?
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20140207/2db2bd90/attachment.pgp>


More information about the Spice-devel mailing list