diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-06-14 11:50:54 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-06-14 11:50:54 -0500 |
commit | 51c302dfe676c363ad1e35baec563366340a6d34 (patch) | |
tree | 588cdf2d1111f978cc19d6280f283eba69d42bbb | |
parent | 9e64d9ac0e796355361f9547da58398d2521fec2 (diff) | |
download | ayatana-indicator-session-51c302dfe676c363ad1e35baec563366340a6d34.tar.gz ayatana-indicator-session-51c302dfe676c363ad1e35baec563366340a6d34.tar.bz2 ayatana-indicator-session-51c302dfe676c363ad1e35baec563366340a6d34.zip |
use g_clear_object()
-rw-r--r-- | src/gtk-logout-helper.c | 5 | ||||
-rw-r--r-- | src/indicator-session.c | 45 |
2 files changed, 14 insertions, 36 deletions
diff --git a/src/gtk-logout-helper.c b/src/gtk-logout-helper.c index 8b8ff8f..4f23ba2 100644 --- a/src/gtk-logout-helper.c +++ b/src/gtk-logout-helper.c @@ -137,10 +137,7 @@ session_action (LogoutDialogType action) } g_object_unref(sm_proxy); - - if (error != NULL) { - g_error_free(error); - } + g_clear_error (&error); return; } diff --git a/src/indicator-session.c b/src/indicator-session.c index 4bc249e..1af2552 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -214,34 +214,21 @@ indicator_session_init (IndicatorSession *self) static void indicator_session_dispose (GObject *object) { - IndicatorSession * self = INDICATOR_SESSION(object); + IndicatorSession * self = INDICATOR_SESSION(object); - if (self->service != NULL) { - g_object_unref(G_OBJECT(self->service)); - self->service = NULL; - } + g_clear_object (&self->service); + g_clear_object (&self->service_proxy); - if (self->service_proxy != NULL) { - g_object_unref(self->service_proxy); - self->service_proxy = NULL; - } + if (self->service_proxy_cancel != NULL) + { + g_cancellable_cancel(self->service_proxy_cancel); + g_clear_object (&self->service_proxy_cancel); + } - if (self->service_proxy_cancel != NULL) { - g_cancellable_cancel(self->service_proxy_cancel); - g_object_unref(self->service_proxy_cancel); - self->service_proxy_cancel = NULL; - } - - if (self->users.menu != NULL) { - g_object_unref (self->users.menu); - } - - if (self->devices.menu != NULL) { - g_object_unref (self->devices.menu); - } + g_clear_object (&self->users.menu); + g_clear_object (&self->devices.menu); - G_OBJECT_CLASS (indicator_session_parent_class)->dispose (object); - return; + G_OBJECT_CLASS (indicator_session_parent_class)->dispose (object); } static void @@ -266,10 +253,7 @@ indicator_session_get_entries (IndicatorObject* obj) } retval = g_list_prepend (retval, &self->devices); - if (retval != NULL) { - retval = g_list_reverse(retval); - } - return retval; + return g_list_reverse (retval); } static guint @@ -341,10 +325,7 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); - if (self->service_proxy_cancel != NULL) { - g_object_unref(self->service_proxy_cancel); - self->service_proxy_cancel = NULL; - } + g_clear_object (&self->service_proxy_cancel); if (error != NULL) { g_warning("Could not grab DBus proxy for %s: %s", INDICATOR_SESSION_DBUS_NAME, error->message); |