[gnome-software/289-uninstalling-an-app-with-installed-add-ons-doesn-t-update-the-add-ons-gui] packagekit: Update addon's state on an application removal




commit 739a779fb03f252b3775984a2082ed4987595097
Author: Milan Crha <mcrha redhat com>
Date:   Wed Apr 28 12:34:05 2021 +0200

    packagekit: Update addon's state on an application removal
    
    When an application is removed, its addons might be removed as well. Update
    the addons' state as well, to make sure it reflects the current state.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/289

 plugins/packagekit/gs-plugin-packagekit.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index cce43b327..3affa7aaa 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -521,8 +521,9 @@ gs_plugin_app_remove (GsPlugin *plugin,
        GsPluginData *priv = gs_plugin_get_data (plugin);
        const gchar *package_id;
        GPtrArray *source_ids;
+       GsAppList *addons;
        g_autoptr(GsPackagekitHelper) helper = gs_packagekit_helper_new (plugin);
-       guint i;
+       guint i, sz;
        guint cnt = 0;
        g_autoptr(PkResults) results = NULL;
        g_auto(GStrv) package_ids = NULL;
@@ -576,6 +577,16 @@ gs_plugin_app_remove (GsPlugin *plugin,
                return FALSE;
        }
 
+       addons = gs_app_get_addons (app);
+       sz = addons ? gs_app_list_length (addons) : 0;
+
+       /* Make sure addons' state is updated as well */
+       for (i = 0; i < sz; i++) {
+               GsApp *addon = gs_app_list_index (addons, i);
+               if (gs_app_get_state (addon) == GS_APP_STATE_INSTALLED)
+                       gs_app_set_state (addon, GS_APP_STATE_UNKNOWN);
+       }
+
        /* state is not known: we don't know if we can re-install this app */
        gs_app_set_state (app, GS_APP_STATE_UNKNOWN);
 


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