[gnome-settings-daemon/gnome-3-2] printers: Move expensive initialization to an idle



commit 514fc674f871a954bf9d800e3682251367a5d2bb
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Apr 23 17:14:28 2012 +0200

    printers: Move expensive initialization to an idle
    
    The start() function is running before gsd finishes its
    session registration, so everything we do here is in the
    critical path for session startup. Both cupsGetDests and
    the subscription registration are potentially expensive,
    and can very well be done later.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674551

 .../gsd-print-notifications-manager.c              |   41 ++++++++++++++------
 1 files changed, 29 insertions(+), 12 deletions(-)
---
diff --git a/plugins/print-notifications/gsd-print-notifications-manager.c b/plugins/print-notifications/gsd-print-notifications-manager.c
index 51bc156..69ea0c7 100644
--- a/plugins/print-notifications/gsd-print-notifications-manager.c
+++ b/plugins/print-notifications/gsd-print-notifications-manager.c
@@ -830,25 +830,17 @@ renew_subscription (gpointer data)
         return TRUE;
 }
 
-gboolean
-gsd_print_notifications_manager_start (GsdPrintNotificationsManager *manager,
-                                       GError                      **error)
+static gboolean
+gsd_print_notifications_manager_start_idle (gpointer data)
 {
-        g_debug ("Starting print-notifications manager");
+        GsdPrintNotificationsManager *manager = data;
 
         gnome_settings_profile_start (NULL);
 
-        manager->priv->subscription_id = -1;
-        manager->priv->dests = NULL;
-        manager->priv->num_dests = 0;
-        manager->priv->scp_handler_spawned = FALSE;
-        manager->priv->timeouts = NULL;
         manager->priv->printing_printers = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-        manager->priv->active_notifications = NULL;
 
         renew_subscription (manager);
         g_timeout_add_seconds (RENEW_INTERVAL, renew_subscription, manager);
-        gnome_settings_profile_msg ("renewed subscriptions");
 
         manager->priv->num_dests = cupsGetDests (&manager->priv->dests);
         gnome_settings_profile_msg ("got dests");
@@ -870,6 +862,30 @@ gsd_print_notifications_manager_start (GsdPrintNotificationsManager *manager,
 
         gnome_settings_profile_end (NULL);
 
+        return FALSE;
+}
+
+gboolean
+gsd_print_notifications_manager_start (GsdPrintNotificationsManager *manager,
+                                       GError                      **error)
+{
+        g_debug ("Starting print-notifications manager");
+
+        gnome_settings_profile_start (NULL);
+
+        manager->priv->subscription_id = -1;
+        manager->priv->dests = NULL;
+        manager->priv->num_dests = 0;
+        manager->priv->scp_handler_spawned = FALSE;
+        manager->priv->timeouts = NULL;
+        manager->priv->printing_printers = NULL;
+        manager->priv->active_notifications = NULL;
+        manager->priv->cups_bus_connection = NULL;
+
+        g_idle_add (gsd_print_notifications_manager_start_idle, manager);
+
+        gnome_settings_profile_end (NULL);
+
         return TRUE;
 }
 
@@ -889,7 +905,8 @@ gsd_print_notifications_manager_stop (GsdPrintNotificationsManager *manager)
         if (manager->priv->subscription_id >= 0)
                 cancel_subscription (manager->priv->subscription_id);
 
-        g_hash_table_destroy (manager->priv->printing_printers);
+        if (manager->priv->printing_printers)
+                g_hash_table_destroy (manager->priv->printing_printers);
 
         g_clear_object (&manager->priv->cups_bus_connection);
 



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