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




commit 0c28a20d6faa6fd3f139b3df5a876aca25d004bb
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 | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index cce43b327..e302945f7 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -521,6 +521,7 @@ 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 cnt = 0;
@@ -576,6 +577,14 @@ gs_plugin_app_remove (GsPlugin *plugin,
                return FALSE;
        }
 
+       /* Make sure addons' state is updated as well */
+       addons = gs_app_get_addons (app);
+       for (i = 0; i < gs_app_list_length (addons); 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]