Blob Blame Raw
From e1672162fc37c37fb09450991316fbfe22029882 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 27 Sep 2017 10:39:05 -0400
Subject: [PATCH 01/13] lib: move g_object_ref call for clarity

create_new_user creates an ActUser object and returns it to
the caller.  Before returning the object, it also adds the
object to a list of "new users" to track when it fully loads.

It's idiomatic to return the original ref to the caller of
a constructor, but create_new_user instead gives the original
reference to the new_users list.  Their's no practical difference,
but this commit moves the ref around for clarity.
---
 src/libaccountsservice/act-user-manager.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c
index 914a1c9..d866725 100644
--- a/src/libaccountsservice/act-user-manager.c
+++ b/src/libaccountsservice/act-user-manager.c
@@ -816,65 +816,65 @@ static void
 add_session_for_user (ActUserManager *manager,
                       ActUser        *user,
                       const char     *ssid,
                       gboolean        is_ours)
 {
         g_hash_table_insert (manager->priv->sessions,
                              g_strdup (ssid),
                              g_object_ref (user));
 
         _act_user_add_session (user, ssid, is_ours);
         g_debug ("ActUserManager: added session for %s", describe_user (user));
 }
 
 static void
 set_has_multiple_users (ActUserManager *manager,
                         gboolean        has_multiple_users)
 {
         if (manager->priv->has_multiple_users != has_multiple_users) {
                 manager->priv->has_multiple_users = has_multiple_users;
                 g_object_notify (G_OBJECT (manager), "has-multiple-users");
         }
 }
 
 static ActUser *
 create_new_user (ActUserManager *manager)
 {
         ActUser *user;
 
         user = g_object_new (ACT_TYPE_USER, NULL);
 
-        manager->priv->new_users = g_slist_prepend (manager->priv->new_users, user);
+        manager->priv->new_users = g_slist_prepend (manager->priv->new_users, g_object_ref (user));
 
         g_signal_connect_object (user, "notify::is-loaded", G_CALLBACK (on_new_user_loaded), manager, 0);
 
-        return g_object_ref (user);
+        return user;
 }
 
 static void
 add_user (ActUserManager *manager,
           ActUser        *user)
 {
         const char *object_path;
 
         g_debug ("ActUserManager: tracking user '%s'", act_user_get_user_name (user));
         if (act_user_is_system_account (user)) {
                 g_hash_table_insert (manager->priv->system_users_by_name,
                                      g_strdup (act_user_get_user_name (user)),
                                      g_object_ref (user));
         } else {
                 g_hash_table_insert (manager->priv->normal_users_by_name,
                                      g_strdup (act_user_get_user_name (user)),
                                      g_object_ref (user));
         }
 
         object_path = act_user_get_object_path (user);
         if (object_path != NULL) {
                 g_hash_table_replace (manager->priv->users_by_object_path,
                                       (gpointer) object_path,
                                       g_object_ref (user));
         }
 
         g_signal_connect_object (user,
                                  "sessions-changed",
                                  G_CALLBACK (on_user_sessions_changed),
                                  manager, 0);
-- 
2.14.1