From 4068c31f16b4964c755c601b475c84ff8555cf7e Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Sat, 8 Feb 2014 17:33:57 -0500 Subject: [PATCH] Add better cleanup as lightdm daemon closes --- common/user-list.c | 8 ++++++++ common/user-list.h | 2 ++ src/lightdm.c | 11 ++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/common/user-list.c b/common/user-list.c index d64e615f..e97377b3 100644 --- a/common/user-list.c +++ b/common/user-list.c @@ -183,6 +183,14 @@ common_user_list_get_instance (void) return singleton; } +void +common_user_list_cleanup (void) +{ + if (singleton) + g_object_unref (singleton); + singleton = NULL; +} + static CommonUser * get_user_by_name (CommonUserList *user_list, const gchar *username) { diff --git a/common/user-list.h b/common/user-list.h index 820e0b25..0d38cfe9 100644 --- a/common/user-list.h +++ b/common/user-list.h @@ -64,6 +64,8 @@ GType common_user_get_type (void); CommonUserList *common_user_list_get_instance (void); +void common_user_list_cleanup (void); + gint common_user_list_get_length (CommonUserList *user_list); CommonUser *common_user_list_get_user_by_name (CommonUserList *user_list, const gchar *username); diff --git a/src/lightdm.c b/src/lightdm.c index 7d35034d..42d47ee0 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -30,6 +30,7 @@ #include "x-server.h" #include "process.h" #include "session-child.h" +#include "user-list.h" static gchar *config_path = NULL; static GMainLoop *loop = NULL; @@ -42,7 +43,7 @@ static XDMCPServer *xdmcp_server = NULL; static VNCServer *vnc_server = NULL; static guint bus_id = 0; static GDBusConnection *bus = NULL; -static guint bus_id; +static guint reg_id = 0; static GDBusNodeInfo *seat_info; static GHashTable *seat_bus_entries = NULL; static guint seat_index = 0; @@ -787,13 +788,13 @@ bus_acquired_cb (GDBusConnection *connection, session_info = g_dbus_node_info_new_for_xml (session_interface, NULL); g_assert (session_info != NULL); - bus_id = g_dbus_connection_register_object (connection, + reg_id = g_dbus_connection_register_object (connection, "/org/freedesktop/DisplayManager", display_manager_info->interfaces[0], &display_manager_vtable, NULL, NULL, &error); - if (bus_id == 0) + if (reg_id == 0) g_warning ("Failed to register display manager: %s", error->message); g_clear_error (&error); g_dbus_node_info_unref (display_manager_info); @@ -1319,11 +1320,15 @@ main (int argc, char **argv) g_main_loop_run (loop); + /* Clean up user list */ + common_user_list_cleanup (); + /* Clean up display manager */ g_object_unref (display_manager); display_manager = NULL; /* Remove D-Bus interface */ + g_dbus_connection_unregister_object (bus, reg_id); g_bus_unown_name (bus_id); if (seat_bus_entries) g_hash_table_unref (seat_bus_entries); -- 2.39.2