summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Grunt <pgrunt@redhat.com>2016-04-06 15:40:11 +0200
committerPavel Grunt <pgrunt@redhat.com>2016-04-07 11:53:24 +0200
commitc9c2cf308167c391a4cfb381adb0b3b5ea29e03d (patch)
tree5a31ecbfa78ec5cae5a3fb4c5a88fe94ce760d94
parent3c6c563328b67d8dbc089d24fead118dc9ed3667 (diff)
Use g_clear_object if possible
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
-rw-r--r--src/spice-channel.c11
-rw-r--r--src/spice-widget.c22
-rw-r--r--src/wocky-http-proxy.c3
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)
{