[gdm/gnome-2-30] Add maybe_set_is_loaded function



commit fe4960c1c6a9b1bf290cae7fd7b387c8fb1fbc9b
Author: Ray Strode <rstrode redhat com>
Date:   Wed Jun 23 22:19:20 2010 -0400

    Add maybe_set_is_loaded function
    
    The is-loaded property is set when the user manager has finished
    doing its various asynchronous tasks related to conjuring the
    list of users available on the system.
    
    The property value changing to TRUE signifies that the
    gdm_user_manager_list_users function can legally be called.
    
    Concretely, is-loaded should only be set to TRUE when both the
    passwd file and ConsoleKit history file have finished loading.
    
    This commit enforces those invariants more explicitly by
    replacing all set_is_loaded calls with a new function
    maybe_set_is_loaded that does the prerequisite checks.
    
    This means as the code evolves, if there are future asynchronous
    tasks to wait on, one function can be modified instead of
    several.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=622639

 gui/simple-greeter/gdm-user-manager.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-user-manager.c b/gui/simple-greeter/gdm-user-manager.c
index 2b9d2a9..f9eff90 100644
--- a/gui/simple-greeter/gdm-user-manager.c
+++ b/gui/simple-greeter/gdm-user-manager.c
@@ -1150,6 +1150,24 @@ set_is_loaded (GdmUserManager *manager,
         }
 }
 
+static void
+maybe_set_is_loaded (GdmUserManager *manager)
+{
+        if (manager->priv->is_loaded) {
+                return;
+        }
+
+        if (manager->priv->ck_history_pid != 0) {
+                return;
+        }
+
+        if (manager->priv->load_passwd_pending) {
+                return;
+        }
+
+        set_is_loaded (manager, TRUE);
+}
+
 static gboolean
 ck_history_watch (GIOChannel     *source,
                   GIOCondition    condition,
@@ -1191,9 +1209,7 @@ ck_history_watch (GIOChannel     *source,
                         manager->priv->ck_history_pid = 0;
                 }
 
-                if (! manager->priv->load_passwd_pending) {
-                        set_is_loaded (manager, TRUE);
-                }
+                maybe_set_is_loaded (manager);
 
                 return FALSE;
         }
@@ -1533,20 +1549,16 @@ reload_passwd_job_done (PasswdData *data)
                 remove_user (data->manager, l->data);
         }
 
+        data->manager->priv->load_passwd_pending = FALSE;
+
         if (! data->manager->priv->is_loaded) {
-                /* if there is an outstanding history
-                   request then wait to emit loaded */
-                if (data->manager->priv->ck_history_pid == 0) {
-                        set_is_loaded (data->manager, TRUE);
-                }
+                maybe_set_is_loaded (data->manager);
 
                 if (data->manager->priv->include_all == TRUE) {
                         monitor_local_users (data->manager);
                 }
         }
 
-        data->manager->priv->load_passwd_pending = FALSE;
-
 
         passwd_data_free (data);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]