[PATCH spice-gtk v2 5/6] Use g_clear_object if possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Acked-by: Eduardo Lima (Etrunko) <etrunko@xxxxxxxxxx>
---
kept separated per Christophe's suggestion
---
 src/spice-channel.c    | 11 ++---------
 src/spice-widget.c     | 22 ++++------------------
 src/wocky-http-proxy.c |  3 +--
 3 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/src/spice-channel.c b/src/spice-channel.c
index 8ae0e4d..e9c5a1b 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -155,10 +155,7 @@ static void spice_channel_dispose(GObject *gobject)
 
     spice_channel_disconnect(channel, SPICE_CHANNEL_CLOSED);
 
-    if (c->session) {
-         g_object_unref(c->session);
-         c->session = NULL;
-    }
+    g_clear_object(&c->session);
 
     g_clear_error(&c->error);
 
@@ -2718,11 +2715,7 @@ static void channel_reset(SpiceChannel *channel, gboolean migrating)
         c->ctx = NULL;
     }
 
-    if (c->conn) {
-        g_object_unref(c->conn);
-        c->conn = NULL;
-    }
-
+    g_clear_object(&c->conn);
     g_clear_object(&c->sock);
 
     c->fd = -1;
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 8ca8631..72a0355 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -439,20 +439,9 @@ static void spice_display_finalize(GObject *obj)
     g_free(d->activeseq);
     d->activeseq = NULL;
 
-    if (d->show_cursor) {
-        g_object_unref(d->show_cursor);
-        d->show_cursor = NULL;
-    }
-
-    if (d->mouse_cursor) {
-        g_object_unref(d->mouse_cursor);
-        d->mouse_cursor = NULL;
-    }
-
-    if (d->mouse_pixbuf) {
-        g_object_unref(d->mouse_pixbuf);
-        d->mouse_pixbuf = NULL;
-    }
+    g_clear_object(&d->show_cursor);
+    g_clear_object(&d->mouse_cursor);
+    g_clear_object(&d->mouse_pixbuf);
 
     G_OBJECT_CLASS(spice_display_parent_class)->finalize(obj);
 }
@@ -2343,10 +2332,7 @@ static void cursor_set(SpiceCursorChannel *channel,
 
     cursor_invalidate(display);
 
-    if (d->mouse_pixbuf) {
-        g_object_unref(d->mouse_pixbuf);
-        d->mouse_pixbuf = NULL;
-    }
+    g_clear_object(&d->mouse_pixbuf);
 
     if (rgba != NULL) {
         d->mouse_pixbuf = gdk_pixbuf_new_from_data(g_memdup(rgba, width * height * 4),
diff --git a/src/wocky-http-proxy.c b/src/wocky-http-proxy.c
index a1a030a..33d57d8 100644
--- a/src/wocky-http-proxy.c
+++ b/src/wocky-http-proxy.c
@@ -222,8 +222,7 @@ wocky_http_proxy_connect (GProxy *proxy,
   g_free (buffer);
   buffer = g_data_input_stream_read_until (data_in, HTTP_END_MARKER, NULL,
       cancellable, error);
-  g_object_unref (data_in);
-  data_in = NULL;
+  g_clear_object(&data_in);
 
   if (buffer == NULL)
     {
-- 
2.8.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]