[gnome-software: 1/2] gs-plugin-loader: Clear pending action on app once task is done




commit b0e6a8b16c437a5991b93ebaabd9812194e9723b
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Nov 25 22:16:59 2020 +0000

    gs-plugin-loader: Clear pending action on app once task is done
    
    This typically manifests in the progress bar not disappearing from the
    details page if installing an app fails.
    
    Normally, when an app is installed, calling `gs_app_set_state()` to
    change it to the `INSTALLED` state will clear the pending action.
    However, if the installation fails early on, before the state change to
    `INSTALLING`, the app’s state doesn’t need to be reverted, so its
    pending action never gets cleared.
    
    Since the pending action is originally set in
    `gs_plugin_loader_schedule_task()`, it makes sense to clear that pending
    action in `gs_plugin_loader_process_in_thread_pool_cb()`, which is the
    paired function which actually runs the task.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Fixes: #744

 lib/gs-plugin-loader.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 1c69deea..07ffaecf 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3543,10 +3543,18 @@ gs_plugin_loader_process_in_thread_pool_cb (gpointer data,
        gpointer source_object = g_task_get_source_object (task);
        gpointer task_data = g_task_get_task_data (task);
        GCancellable *cancellable = g_task_get_cancellable (task);
+       GsPluginLoaderHelper *helper = g_task_get_task_data (task);
+       GsApp *app = gs_plugin_job_get_app (helper->plugin_job);
+       GsPluginAction action = gs_plugin_job_get_action (helper->plugin_job);
 
        gs_ioprio_init ();
 
        gs_plugin_loader_process_thread_cb (task, source_object, task_data, cancellable);
+
+       /* Clear any pending action set in gs_plugin_loader_schedule_task() */
+       if (app != NULL && gs_app_get_pending_action (app) == action)
+               gs_app_set_pending_action (app, GS_PLUGIN_ACTION_UNKNOWN);
+
        g_object_unref (task);
 }
 


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