summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2015-10-16 11:04:18 +0100
committerRobert Ancell <robert.ancell@canonical.com>2015-10-16 11:04:18 +0100
commitaef36c92e606fef5789fda5b680e861c62939a90 (patch)
tree810537aca44f300000ecbabe20b4d3ae18076249
parent5b1596558dd7e01b892479fa32b46757b7566ee2 (diff)
downloadlightdm-aef36c92e606fef5789fda5b680e861c62939a90.tar.gz
Tidy up finalize methods
-rw-r--r--common/configuration.c4
-rw-r--r--common/user-list.c3
-rw-r--r--src/display-manager.c4
-rw-r--r--src/display-server.c4
-rw-r--r--src/greeter.c4
-rw-r--r--src/login1.c2
-rw-r--r--src/mir-server.c10
-rw-r--r--src/process.c4
-rw-r--r--src/seat-unity.c9
-rw-r--r--src/seat-xdmcp-session.c6
-rw-r--r--src/seat-xvnc.c6
-rw-r--r--src/seat.c16
-rw-r--r--src/session.c12
-rw-r--r--src/unity-system-compositor.c4
-rw-r--r--src/vnc-server.c10
-rw-r--r--src/wayland-session.c4
-rw-r--r--src/x-authority.c4
-rw-r--r--src/x-server-local.c4
-rw-r--r--src/x-server-xvnc.c7
-rw-r--r--src/x-server.c7
-rw-r--r--src/xdmcp-server.c10
-rw-r--r--src/xdmcp-session.c10
22 files changed, 44 insertions, 100 deletions
diff --git a/common/configuration.c b/common/configuration.c
index 895085e3..dc7831a8 100644
--- a/common/configuration.c
+++ b/common/configuration.c
@@ -331,9 +331,7 @@ config_init (Configuration *config)
static void
config_finalize (GObject *object)
{
- Configuration *self;
-
- self = CONFIGURATION (object);
+ Configuration *self = CONFIGURATION (object);
g_free (self->priv->dir);
g_key_file_free (self->priv->key_file);
diff --git a/common/user-list.c b/common/user-list.c
index 792c6d3a..2598bd49 100644
--- a/common/user-list.c
+++ b/common/user-list.c
@@ -1059,8 +1059,7 @@ common_user_list_finalize (GObject *object)
if (priv->session_removed_signal)
g_dbus_connection_signal_unsubscribe (priv->bus, priv->session_removed_signal);
g_object_unref (priv->bus);
- if (priv->passwd_monitor)
- g_object_unref (priv->passwd_monitor);
+ g_clear_object (&priv->passwd_monitor);
G_OBJECT_CLASS (common_user_list_parent_class)->finalize (object);
}
diff --git a/src/display-manager.c b/src/display-manager.c
index b683fdaa..af9f43a4 100644
--- a/src/display-manager.c
+++ b/src/display-manager.c
@@ -170,11 +170,9 @@ display_manager_init (DisplayManager *manager)
static void
display_manager_finalize (GObject *object)
{
- DisplayManager *self;
+ DisplayManager *self = DISPLAY_MANAGER (object);
GList *link;
- self = DISPLAY_MANAGER (object);
-
for (link = self->priv->seats; link; link = link->next)
{
Seat *seat = link->data;
diff --git a/src/display-server.c b/src/display-server.c
index 336a6eed..7821b6ab 100644
--- a/src/display-server.c
+++ b/src/display-server.c
@@ -154,9 +154,7 @@ display_server_init (DisplayServer *server)
static void
display_server_finalize (GObject *object)
{
- DisplayServer *self;
-
- self = DISPLAY_SERVER (object);
+ DisplayServer *self = DISPLAY_SERVER (object);
g_free (self->priv->name);
diff --git a/src/greeter.c b/src/greeter.c
index b9f4f55a..5e33ee6d 100644
--- a/src/greeter.c
+++ b/src/greeter.c
@@ -1043,9 +1043,7 @@ greeter_init (Greeter *greeter)
static void
greeter_finalize (GObject *object)
{
- Greeter *self;
-
- self = GREETER (object);
+ Greeter *self = GREETER (object);
g_free (self->priv->pam_service);
g_free (self->priv->autologin_pam_service);
diff --git a/src/login1.c b/src/login1.c
index af8e8a8e..dc60a492 100644
--- a/src/login1.c
+++ b/src/login1.c
@@ -450,7 +450,7 @@ login1_service_finalize (GObject *object)
g_list_free_full (self->priv->seats, g_object_unref);
g_dbus_connection_signal_unsubscribe (self->priv->connection, self->priv->signal_id);
- g_object_unref (self->priv->connection);
+ g_clear_object (&self->priv->connection);
G_OBJECT_CLASS (login1_service_parent_class)->finalize (object);
}
diff --git a/src/mir-server.c b/src/mir-server.c
index 36e0e770..303f3d56 100644
--- a/src/mir-server.c
+++ b/src/mir-server.c
@@ -99,13 +99,11 @@ mir_server_init (MirServer *server)
static void
mir_server_finalize (GObject *object)
{
- MirServer *server;
-
- server = MIR_SERVER (object);
+ MirServer *self = MIR_SERVER (object);
- if (server->priv->vt > 0)
- vt_unref (server->priv->vt);
- g_free (server->priv->parent_socket);
+ if (self->priv->vt > 0)
+ vt_unref (self->priv->vt);
+ g_free (self->priv->parent_socket);
G_OBJECT_CLASS (mir_server_parent_class)->finalize (object);
}
diff --git a/src/process.c b/src/process.c
index 50c0a9b0..ebd12743 100644
--- a/src/process.c
+++ b/src/process.c
@@ -359,9 +359,7 @@ process_stopped (Process *process)
static void
process_finalize (GObject *object)
{
- Process *self;
-
- self = PROCESS (object);
+ Process *self = PROCESS (object);
if (self->priv->pid > 0)
g_hash_table_remove (processes, GINT_TO_POINTER (self->priv->pid));
diff --git a/src/seat-unity.c b/src/seat-unity.c
index 642be0aa..5e3438f5 100644
--- a/src/seat-unity.c
+++ b/src/seat-unity.c
@@ -421,17 +421,14 @@ seat_unity_finalize (GObject *object)
{
SeatUnity *seat = SEAT_UNITY (object);
- if (seat->priv->compositor)
- g_object_unref (seat->priv->compositor);
+ g_clear_object (&seat->priv->compositor);
if (seat->priv->xdmcp_x_server)
{
g_signal_handlers_disconnect_matched (seat->priv->xdmcp_x_server, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, seat);
g_object_unref (seat->priv->xdmcp_x_server);
}
- if (seat->priv->active_session)
- g_object_unref (seat->priv->active_session);
- if (seat->priv->active_display_server)
- g_object_unref (seat->priv->active_display_server);
+ g_clear_object (&seat->priv->active_session);
+ g_clear_object (&seat->priv->active_display_server);
G_OBJECT_CLASS (seat_unity_parent_class)->finalize (object);
}
diff --git a/src/seat-xdmcp-session.c b/src/seat-xdmcp-session.c
index 7621a97b..41998279 100644
--- a/src/seat-xdmcp-session.c
+++ b/src/seat-xdmcp-session.c
@@ -60,11 +60,9 @@ seat_xdmcp_session_init (SeatXDMCPSession *seat)
static void
seat_xdmcp_session_finalize (GObject *object)
{
- SeatXDMCPSession *self;
+ SeatXDMCPSession *self = SEAT_XDMCP_SESSION (object);
- self = SEAT_XDMCP_SESSION (object);
-
- g_object_unref (self->priv->session);
+ g_clear_object (&self->priv->session);
G_OBJECT_CLASS (seat_xdmcp_session_parent_class)->finalize (object);
}
diff --git a/src/seat-xvnc.c b/src/seat-xvnc.c
index 00f5f693..93e0e13f 100644
--- a/src/seat-xvnc.c
+++ b/src/seat-xvnc.c
@@ -101,11 +101,9 @@ seat_xvnc_init (SeatXVNC *seat)
static void
seat_xdmcp_session_finalize (GObject *object)
{
- SeatXVNC *self;
+ SeatXVNC *self = SEAT_XVNC (object);
- self = SEAT_XVNC (object);
-
- g_object_unref (self->priv->connection);
+ g_clear_object (&self->priv->connection);
G_OBJECT_CLASS (seat_xvnc_parent_class)->finalize (object);
}
diff --git a/src/seat.c b/src/seat.c
index 13624ccb..857aa1b0 100644
--- a/src/seat.c
+++ b/src/seat.c
@@ -1899,11 +1899,9 @@ seat_init (Seat *seat)
static void
seat_finalize (GObject *object)
{
- Seat *self;
+ Seat *self = SEAT (object);
GList *link;
- self = SEAT (object);
-
g_free (self->priv->name);
g_hash_table_unref (self->priv->properties);
for (link = self->priv->display_servers; link; link = link->next)
@@ -1918,14 +1916,10 @@ seat_finalize (GObject *object)
g_signal_handlers_disconnect_matched (session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self);
}
g_list_free_full (self->priv->sessions, g_object_unref);
- if (self->priv->active_session)
- g_object_unref (self->priv->active_session);
- if (self->priv->next_session)
- g_object_unref (self->priv->next_session);
- if (self->priv->session_to_activate)
- g_object_unref (self->priv->session_to_activate);
- if (self->priv->replacement_greeter)
- g_object_unref (self->priv->replacement_greeter);
+ g_clear_object (&self->priv->active_session);
+ g_clear_object (&self->priv->next_session);
+ g_clear_object (&self->priv->session_to_activate);
+ g_clear_object (&self->priv->replacement_greeter);
G_OBJECT_CLASS (seat_parent_class)->finalize (object);
}
diff --git a/src/session.c b/src/session.c
index e25a69a5..1f278d10 100644
--- a/src/session.c
+++ b/src/session.c
@@ -920,10 +920,8 @@ session_finalize (GObject *object)
Session *self = SESSION (object);
int i;
- if (self->priv->config)
- g_object_unref (self->priv->config);
- if (self->priv->display_server)
- g_object_unref (self->priv->display_server);
+ g_clear_object (&self->priv->config);
+ g_clear_object (&self->priv->display_server);
if (self->priv->pid)
kill (self->priv->pid, SIGKILL);
close (self->priv->to_child_input);
@@ -935,8 +933,7 @@ session_finalize (GObject *object)
if (self->priv->child_watch)
g_source_remove (self->priv->child_watch);
g_free (self->priv->username);
- if (self->priv->user)
- g_object_unref (self->priv->user);
+ g_clear_object (&self->priv->user);
g_free (self->priv->pam_service);
for (i = 0; i < self->priv->messages_length; i++)
g_free ((char *) self->priv->messages[i].msg);
@@ -945,8 +942,7 @@ session_finalize (GObject *object)
g_free (self->priv->log_filename);
g_free (self->priv->tty);
g_free (self->priv->xdisplay);
- if (self->priv->x_authority)
- g_object_unref (self->priv->x_authority);
+ g_clear_object (&self->priv->x_authority);
g_free (self->priv->remote_host_name);
g_free (self->priv->login1_session_id);
g_free (self->priv->console_kit_cookie);
diff --git a/src/unity-system-compositor.c b/src/unity-system-compositor.c
index f4b74eb1..0b89d2c2 100644
--- a/src/unity-system-compositor.c
+++ b/src/unity-system-compositor.c
@@ -482,9 +482,7 @@ unity_system_compositor_init (UnitySystemCompositor *compositor)
static void
unity_system_compositor_finalize (GObject *object)
{
- UnitySystemCompositor *self;
-
- self = UNITY_SYSTEM_COMPOSITOR (object);
+ UnitySystemCompositor *self = UNITY_SYSTEM_COMPOSITOR (object);
if (self->priv->process)
{
diff --git a/src/vnc-server.c b/src/vnc-server.c
index d4e6e9d9..914a5ebd 100644
--- a/src/vnc-server.c
+++ b/src/vnc-server.c
@@ -179,15 +179,11 @@ vnc_server_init (VNCServer *server)
static void
vnc_server_finalize (GObject *object)
{
- VNCServer *self;
-
- self = VNC_SERVER (object);
+ VNCServer *self = VNC_SERVER (object);
g_free (self->priv->listen_address);
- if (self->priv->socket)
- g_object_unref (self->priv->socket);
- if (self->priv->socket6)
- g_object_unref (self->priv->socket6);
+ g_clear_object (&self->priv->socket);
+ g_clear_object (&self->priv->socket6);
G_OBJECT_CLASS (vnc_server_parent_class)->finalize (object);
}
diff --git a/src/wayland-session.c b/src/wayland-session.c
index 19a50aa5..639893ea 100644
--- a/src/wayland-session.c
+++ b/src/wayland-session.c
@@ -81,9 +81,7 @@ wayland_session_init (WaylandSession *session)
static void
wayland_session_finalize (GObject *object)
{
- WaylandSession *self;
-
- self = WAYLAND_SESSION (object);
+ WaylandSession *self = WAYLAND_SESSION (object);
if (self->priv->have_vt_ref)
vt_unref (self->priv->vt);
diff --git a/src/x-authority.c b/src/x-authority.c
index 25f66438..6e08d12e 100644
--- a/src/x-authority.c
+++ b/src/x-authority.c
@@ -372,9 +372,7 @@ x_authority_init (XAuthority *auth)
static void
x_authority_finalize (GObject *object)
{
- XAuthority *self;
-
- self = X_AUTHORITY (object);
+ XAuthority *self = X_AUTHORITY (object);
g_free (self->priv->address);
g_free (self->priv->number);
diff --git a/src/x-server-local.c b/src/x-server-local.c
index d9b03982..dcbfbc0a 100644
--- a/src/x-server-local.c
+++ b/src/x-server-local.c
@@ -610,9 +610,7 @@ x_server_local_init (XServerLocal *server)
static void
x_server_local_finalize (GObject *object)
{
- XServerLocal *self;
-
- self = X_SERVER_LOCAL (object);
+ XServerLocal *self = X_SERVER_LOCAL (object);
if (self->priv->x_server_process)
{
diff --git a/src/x-server-xvnc.c b/src/x-server-xvnc.c
index a48290e5..e5edd1ac 100644
--- a/src/x-server-xvnc.c
+++ b/src/x-server-xvnc.c
@@ -291,12 +291,9 @@ x_server_xvnc_init (XServerXVNC *server)
static void
x_server_xvnc_finalize (GObject *object)
{
- XServerXVNC *self;
+ XServerXVNC *self = X_SERVER_XVNC (object);
- self = X_SERVER_XVNC (object);
-
- if (self->priv->x_server_process)
- g_object_unref (self->priv->x_server_process);
+ g_clear_object (&self->priv->x_server_process);
g_free (self->priv->command);
g_free (self->priv->authority_file);
diff --git a/src/x-server.c b/src/x-server.c
index 10ba903a..b82f3c6b 100644
--- a/src/x-server.c
+++ b/src/x-server.c
@@ -204,14 +204,11 @@ x_server_init (XServer *server)
static void
x_server_finalize (GObject *object)
{
- XServer *self;
-
- self = X_SERVER (object);
+ XServer *self = X_SERVER (object);
g_free (self->priv->hostname);
g_free (self->priv->address);
- if (self->priv->authority)
- g_object_unref (self->priv->authority);
+ g_clear_object (&self->priv->authority);
if (self->priv->connection)
xcb_disconnect (self->priv->connection);
diff --git a/src/xdmcp-server.c b/src/xdmcp-server.c
index 197dbc11..4761b7b0 100644
--- a/src/xdmcp-server.c
+++ b/src/xdmcp-server.c
@@ -743,14 +743,10 @@ xdmcp_server_init (XDMCPServer *server)
static void
xdmcp_server_finalize (GObject *object)
{
- XDMCPServer *self;
+ XDMCPServer *self = XDMCP_SERVER (object);
- self = XDMCP_SERVER (object);
-
- if (self->priv->socket)
- g_object_unref (self->priv->socket);
- if (self->priv->socket6)
- g_object_unref (self->priv->socket6);
+ g_clear_object (&self->priv->socket);
+ g_clear_object (&self->priv->socket6);
g_free (self->priv->listen_address);
g_free (self->priv->hostname);
g_free (self->priv->status);
diff --git a/src/xdmcp-session.c b/src/xdmcp-session.c
index 71c5704d..bb78ac66 100644
--- a/src/xdmcp-session.c
+++ b/src/xdmcp-session.c
@@ -77,15 +77,11 @@ xdmcp_session_init (XDMCPSession *session)
static void
xdmcp_session_finalize (GObject *object)
{
- XDMCPSession *self;
-
- self = XDMCP_SESSION (object);
+ XDMCPSession *self = XDMCP_SESSION (object);
g_free (self->priv->manufacturer_display_id);
- if (self->priv->address)
- g_object_unref (self->priv->address);
- if (self->priv->authority)
- g_object_unref (self->priv->authority);
+ g_clear_object (&self->priv->address);
+ g_clear_object (&self->priv->authority);
g_free (self->priv->display_class);
G_OBJECT_CLASS (xdmcp_session_parent_class)->finalize (object);