summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/user-list.c4
-rw-r--r--src/greeter.c3
-rw-r--r--src/lightdm.c3
-rw-r--r--src/seat-unity.c3
-rw-r--r--src/seat.c68
-rw-r--r--src/session.c13
-rw-r--r--src/shared-data-manager.c6
-rw-r--r--src/x-server-xvnc.c3
-rw-r--r--src/x-server.c5
9 files changed, 30 insertions, 78 deletions
diff --git a/common/user-list.c b/common/user-list.c
index 2598bd49..1b198d1a 100644
--- a/common/user-list.c
+++ b/common/user-list.c
@@ -186,9 +186,7 @@ common_user_list_get_instance (void)
void
common_user_list_cleanup (void)
{
- if (singleton)
- g_object_unref (singleton);
- singleton = NULL;
+ g_clear_object (&singleton);
}
static CommonUser *
diff --git a/src/greeter.c b/src/greeter.c
index 5e33ee6d..db52a43d 100644
--- a/src/greeter.c
+++ b/src/greeter.c
@@ -412,8 +412,7 @@ reset_session (Greeter *greeter)
{
g_signal_handlers_disconnect_matched (greeter->priv->authentication_session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, greeter);
session_stop (greeter->priv->authentication_session);
- g_object_unref (greeter->priv->authentication_session);
- greeter->priv->authentication_session = NULL;
+ g_clear_object (&greeter->priv->authentication_session);
}
greeter->priv->guest_account_authenticated = FALSE;
diff --git a/src/lightdm.c b/src/lightdm.c
index 72f7eb0c..d9ec9aff 100644
--- a/src/lightdm.c
+++ b/src/lightdm.c
@@ -1539,8 +1539,7 @@ main (int argc, char **argv)
common_user_list_cleanup ();
/* Clean up display manager */
- g_object_unref (display_manager);
- display_manager = NULL;
+ g_clear_object (&display_manager);
/* Remove D-Bus interface */
g_dbus_connection_unregister_object (bus, reg_id);
diff --git a/src/seat-unity.c b/src/seat-unity.c
index 5e3438f5..409c0a46 100644
--- a/src/seat-unity.c
+++ b/src/seat-unity.c
@@ -140,8 +140,7 @@ compositor_stopped_cb (UnitySystemCompositor *compositor, SeatUnity *seat)
{
l_debug (seat, "Compositor stopped");
- g_object_unref (seat->priv->compositor);
- seat->priv->compositor = NULL;
+ g_clear_object (&seat->priv->compositor);
if (seat_get_is_stopping (SEAT (seat)))
check_stopped (seat);
diff --git a/src/seat.c b/src/seat.c
index 857aa1b0..2e2afd0a 100644
--- a/src/seat.c
+++ b/src/seat.c
@@ -247,14 +247,11 @@ seat_set_active_session (Seat *seat, Session *session)
}
/* Lock previous sessions */
- if (seat->priv->active_session)
- {
- if (session != seat->priv->active_session && !IS_GREETER (seat->priv->active_session))
- session_lock (seat->priv->active_session);
- g_object_unref (seat->priv->active_session);
- }
+ if (seat->priv->active_session && session != seat->priv->active_session && !IS_GREETER (seat->priv->active_session))
+ session_lock (seat->priv->active_session);
session_activate (session);
+ g_clear_object (&seat->priv->active_session);
seat->priv->active_session = g_object_ref (session);
}
@@ -300,8 +297,7 @@ void
seat_set_externally_activated_session (Seat *seat, Session *session)
{
g_return_if_fail (seat != NULL);
- if (seat->priv->active_session)
- g_object_unref (seat->priv->active_session);
+ g_clear_object (&seat->priv->active_session);
seat->priv->active_session = g_object_ref (session);
}
@@ -568,8 +564,7 @@ switch_to_greeter_from_failed_session (Seat *seat, Session *session)
}
else
{
- if (seat->priv->session_to_activate)
- g_object_unref (seat->priv->session_to_activate);
+ g_clear_object (&seat->priv->session_to_activate);
seat->priv->session_to_activate = g_object_ref (greeter_session);
if (can_share_display_server (seat, session_get_display_server (session)))
@@ -654,8 +649,7 @@ run_session (Seat *seat, Session *session)
if (session == seat->priv->session_to_activate)
{
seat_set_active_session (seat, session);
- g_object_unref (seat->priv->session_to_activate);
- seat->priv->session_to_activate = NULL;
+ g_clear_object (&seat->priv->session_to_activate);
}
else if (seat->priv->active_session)
{
@@ -699,8 +693,7 @@ greeter_active_username_changed_cb (Greeter *greeter, GParamSpec *pspec, Seat *s
session = find_user_session (seat, greeter_get_active_username (greeter), seat->priv->active_session);
- if (seat->priv->next_session)
- g_object_unref (seat->priv->next_session);
+ g_clear_object (&seat->priv->next_session);
seat->priv->next_session = session ? g_object_ref (session) : NULL;
SEAT_GET_CLASS (seat)->set_next_session (seat, session);
@@ -748,20 +741,11 @@ session_stopped_cb (Session *session, Seat *seat)
g_signal_handlers_disconnect_matched (session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, seat);
seat->priv->sessions = g_list_remove (seat->priv->sessions, session);
if (session == seat->priv->active_session)
- {
- g_object_unref (seat->priv->active_session);
- seat->priv->active_session = NULL;
- }
+ g_clear_object (&seat->priv->active_session);
if (session == seat->priv->next_session)
- {
- g_object_unref (seat->priv->next_session);
- seat->priv->next_session = NULL;
- }
+ g_clear_object (&seat->priv->next_session);
if (session == seat->priv->session_to_activate)
- {
- g_object_unref (seat->priv->session_to_activate);
- seat->priv->session_to_activate = NULL;
- }
+ g_clear_object (&seat->priv->session_to_activate);
display_server = session_get_display_server (session);
if (!display_server)
@@ -782,10 +766,7 @@ session_stopped_cb (Session *session, Seat *seat)
/* We were waiting for this session, but it didn't start :( */
// FIXME: Start a greeter on this?
if (session == seat->priv->session_to_activate)
- {
- g_object_unref (seat->priv->session_to_activate);
- seat->priv->session_to_activate = NULL;
- }
+ g_clear_object (&seat->priv->session_to_activate);
if (seat->priv->stopping)
{
@@ -1222,8 +1203,7 @@ greeter_start_session_cb (Greeter *greeter, SessionType type, const gchar *sessi
}
/* Switch to this session when it is ready */
- if (seat->priv->session_to_activate)
- g_object_unref (seat->priv->session_to_activate);
+ g_clear_object (&seat->priv->session_to_activate);
seat->priv->session_to_activate = g_object_ref (session);
/* Return to existing session if it is open */
@@ -1454,8 +1434,7 @@ seat_switch_to_greeter (Seat *seat)
if (!greeter_session)
return FALSE;
- if (seat->priv->session_to_activate)
- g_object_unref (seat->priv->session_to_activate);
+ g_clear_object (&seat->priv->session_to_activate);
seat->priv->session_to_activate = g_object_ref (greeter_session);
display_server = create_display_server (seat, SESSION (greeter_session));
@@ -1487,8 +1466,7 @@ switch_authentication_complete_cb (Session *session, Seat *seat)
else
{
l_debug (seat, "Session authenticated, starting display server");
- if (seat->priv->session_to_activate)
- g_object_unref (seat->priv->session_to_activate);
+ g_clear_object (&seat->priv->session_to_activate);
seat->priv->session_to_activate = g_object_ref (session);
display_server = create_display_server (seat, session);
session_set_display_server (session, display_server);
@@ -1526,8 +1504,7 @@ switch_authentication_complete_cb (Session *session, Seat *seat)
}
else
{
- if (seat->priv->session_to_activate)
- g_object_unref (seat->priv->session_to_activate);
+ g_clear_object (&seat->priv->session_to_activate);
seat->priv->session_to_activate = g_object_ref (greeter_session);
display_server = create_display_server (seat, SESSION (greeter_session));
@@ -1603,8 +1580,7 @@ seat_switch_to_guest (Seat *seat, const gchar *session_name)
display_server = create_display_server (seat, session);
- if (seat->priv->session_to_activate)
- g_object_unref (seat->priv->session_to_activate);
+ g_clear_object (&seat->priv->session_to_activate);
seat->priv->session_to_activate = g_object_ref (session);
session_set_pam_service (session, seat_get_string_property (seat, "pam-autologin-service"));
session_set_display_server (session, display_server);
@@ -1673,14 +1649,12 @@ seat_lock (Seat *seat, const gchar *username)
display_server = create_display_server (seat, SESSION (greeter_session));
session_set_display_server (SESSION (greeter_session), display_server);
- if (seat->priv->session_to_activate)
- g_object_unref (seat->priv->session_to_activate);
+ g_clear_object (&seat->priv->session_to_activate);
seat->priv->session_to_activate = g_object_ref (greeter_session);
if (reuse_xserver)
{
- if (seat->priv->replacement_greeter)
- g_object_unref (seat->priv->replacement_greeter);
+ g_clear_object (&seat->priv->replacement_greeter);
seat->priv->replacement_greeter = g_object_ref (greeter_session);
return TRUE;
}
@@ -1753,8 +1727,7 @@ seat_real_start (Seat *seat)
{
DisplayServer *display_server;
- if (seat->priv->session_to_activate)
- g_object_unref (seat->priv->session_to_activate);
+ g_clear_object (&seat->priv->session_to_activate);
seat->priv->session_to_activate = g_object_ref (session);
display_server = create_display_server (seat, session);
@@ -1783,8 +1756,7 @@ seat_real_start (Seat *seat)
return FALSE;
}
- if (seat->priv->session_to_activate)
- g_object_unref (seat->priv->session_to_activate);
+ g_clear_object (&seat->priv->session_to_activate);
seat->priv->session_to_activate = g_object_ref (greeter_session);
session = SESSION (greeter_session);
diff --git a/src/session.c b/src/session.c
index 1f278d10..f7f4ac09 100644
--- a/src/session.c
+++ b/src/session.c
@@ -135,8 +135,7 @@ session_set_config (Session *session, SessionConfig *config)
{
g_return_if_fail (session != NULL);
- if (session->priv->config)
- g_object_unref (session->priv->config);
+ g_clear_object (&session->priv->config);
session->priv->config = g_object_ref (config);
}
@@ -246,11 +245,7 @@ void
session_set_x_authority (Session *session, XAuthority *authority, gboolean use_system_location)
{
g_return_if_fail (session != NULL);
- if (session->priv->x_authority)
- {
- g_object_unref (session->priv->x_authority);
- session->priv->x_authority = NULL;
- }
+ g_clear_object (&session->priv->x_authority);
if (authority)
session->priv->x_authority = g_object_ref (authority);
session->priv->x_authority_use_system_location = use_system_location;
@@ -484,9 +479,7 @@ from_child_cb (GIOChannel *source, GIOCondition condition, gpointer data)
{
g_free (session->priv->username);
session->priv->username = username;
- if (session->priv->user)
- g_object_unref (session->priv->user);
- session->priv->user = NULL;
+ g_clear_object (&session->priv->user);
}
else
g_free (username);
diff --git a/src/shared-data-manager.c b/src/shared-data-manager.c
index 8285a86d..fd7427e3 100644
--- a/src/shared-data-manager.c
+++ b/src/shared-data-manager.c
@@ -49,11 +49,7 @@ shared_data_manager_get_instance (void)
void
shared_data_manager_cleanup (void)
{
- if (singleton)
- {
- g_object_unref (singleton);
- singleton = NULL;
- }
+ g_clear_object (&singleton);
}
static void
diff --git a/src/x-server-xvnc.c b/src/x-server-xvnc.c
index e5edd1ac..aea28177 100644
--- a/src/x-server-xvnc.c
+++ b/src/x-server-xvnc.c
@@ -158,8 +158,7 @@ stopped_cb (Process *process, XServerXVNC *server)
{
l_debug (server, "Xvnc server stopped");
- g_object_unref (server->priv->x_server_process);
- server->priv->x_server_process = NULL;
+ g_clear_object (&server->priv->x_server_process);
x_server_local_release_display_number (x_server_get_display_number (X_SERVER (server)));
diff --git a/src/x-server.c b/src/x-server.c
index b82f3c6b..d0260bef 100644
--- a/src/x-server.c
+++ b/src/x-server.c
@@ -90,12 +90,9 @@ x_server_set_authority (XServer *server, XAuthority *authority)
{
g_return_if_fail (server != NULL);
- if (server->priv->authority)
- g_object_unref (server->priv->authority);
+ g_clear_object (&server->priv->authority);
if (authority)
server->priv->authority = g_object_ref (authority);
- else
- server->priv->authority = NULL;
}
XAuthority *