[gnome-software] offline updates: Fix a race with shutdown dialog showing



commit 6f31ef58654da9beeaae0e4a916076d543ae0a0a
Author: Kalev Lember <kalevlember gmail com>
Date:   Sun Aug 31 18:11:42 2014 +0200

    offline updates: Fix a race with shutdown dialog showing
    
    Wait for pk-trigger-offline-update to finish before showing the shutdown
    dialog; otherwise gnome-shell won't know that it needs to show the
    special update installing dialog and just brings up the regular one.

 src/gs-offline-updates.c |   19 ++++++++++++-------
 src/gs-offline-updates.h |    2 +-
 src/gs-shell-updates.c   |    9 +++++++--
 3 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/src/gs-offline-updates.c b/src/gs-offline-updates.c
index 91adfdd..9fdcd56 100644
--- a/src/gs-offline-updates.c
+++ b/src/gs-offline-updates.c
@@ -30,12 +30,16 @@
 static void
 child_exit_cb (GPid pid, gint status, gpointer user_data)
 {
+       GCallback child_exited = user_data;
+
        g_spawn_close_pid (pid);
-}
 
+       if (child_exited != NULL)
+               child_exited ();
+}
 
 static gboolean
-gs_spawn_pkexec (const gchar *command, const gchar *parameter, GError **error)
+gs_spawn_pkexec (const gchar *command, const gchar *parameter, GCallback child_exited, GError **error)
 {
        GPid pid;
        const gchar *argv[4];
@@ -52,7 +56,8 @@ gs_spawn_pkexec (const gchar *command, const gchar *parameter, GError **error)
                             NULL, NULL, &pid, error);
        if (!ret)
                return FALSE;
-       g_child_watch_add (pid, child_exit_cb, NULL);
+
+       g_child_watch_add (pid, child_exit_cb, child_exited);
        return TRUE;
 }
 
@@ -62,7 +67,7 @@ gs_offline_updates_clear_status (void)
        gboolean ret;
        GError *error = NULL;
 
-       ret = gs_spawn_pkexec (LIBEXECDIR "/pk-clear-offline-update", NULL, &error);
+       ret = gs_spawn_pkexec (LIBEXECDIR "/pk-clear-offline-update", NULL, NULL, &error);
        if (!ret) {
                g_warning ("Failure clearing offline update message: %s",
                           error->message);
@@ -71,12 +76,12 @@ gs_offline_updates_clear_status (void)
 }
 
 void
-gs_offline_updates_trigger (void)
+gs_offline_updates_trigger (GCallback child_exited)
 {
        gboolean ret;
        GError *error = NULL;
 
-       ret = gs_spawn_pkexec (LIBEXECDIR "/pk-trigger-offline-update", NULL, &error);
+       ret = gs_spawn_pkexec (LIBEXECDIR "/pk-trigger-offline-update", NULL, child_exited, &error);
        if (!ret) {
                g_warning ("Failure triggering offline update: %s",
                           error->message);
@@ -91,7 +96,7 @@ gs_offline_updates_cancel (void)
        GError *error = NULL;
 
        ret = gs_spawn_pkexec (LIBEXECDIR "/pk-trigger-offline-update",
-                              "--cancel", &error);
+                              "--cancel", NULL, &error);
        if (!ret) {
                g_warning ("Failure cancelling offline update: %s",
                           error->message);
diff --git a/src/gs-offline-updates.h b/src/gs-offline-updates.h
index 9d6c82f..6059929 100644
--- a/src/gs-offline-updates.h
+++ b/src/gs-offline-updates.h
@@ -26,7 +26,7 @@
 
 G_BEGIN_DECLS
 
-void     gs_offline_updates_trigger            (void);
+void     gs_offline_updates_trigger            (GCallback  child_exited);
 void     gs_offline_updates_cancel             (void);
 void     gs_offline_updates_clear_status       (void);
 gboolean gs_offline_updates_results_available  (void);
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 9679ce2..9b2336b 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -819,11 +819,16 @@ gs_shell_updates_pending_apps_changed_cb (GsPluginLoader *plugin_loader,
 }
 
 static void
+offline_updates_triggered_cb (void)
+{
+       gs_reboot (gs_offline_updates_cancel);
+}
+
+static void
 gs_shell_updates_button_update_all_cb (GtkButton      *button,
                                       GsShellUpdates *updates)
 {
-       gs_offline_updates_trigger ();
-       gs_reboot (gs_offline_updates_cancel);
+       gs_offline_updates_trigger (offline_updates_triggered_cb);
 }
 
 /**


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