[gnome-software] repos dialog: Be more defensive when adding repos



commit 450944eaa17d28601c973f200dbcb69249fcd3ae
Author: Kalev Lember <klember redhat com>
Date:   Fri Feb 23 13:25:06 2018 +0100

    repos dialog: Be more defensive when adding repos
    
    Skip repos that we don't know how to handle and emit a warning.
    
    This fixes google-chrome repo in F27 showing up with an empty button
    text -- the root cause was invalid appstream data entry for the repo,
    but we can try and be more careful here and not show up invalid entries.

 src/gs-repos-dialog.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/gs-repos-dialog.c b/src/gs-repos-dialog.c
index 36666443..cd35ddb2 100644
--- a/src/gs-repos-dialog.c
+++ b/src/gs-repos-dialog.c
@@ -309,6 +309,19 @@ add_repo (GsReposDialog *dialog, GsApp *app)
 {
        GtkWidget *row;
        g_autofree gchar *text = NULL;
+       AsAppState state;
+
+       state = gs_app_get_state (app);
+       if (!(state == AS_APP_STATE_AVAILABLE ||
+             state == AS_APP_STATE_AVAILABLE_LOCAL ||
+             state == AS_APP_STATE_INSTALLED ||
+             state == AS_APP_STATE_INSTALLING ||
+             state == AS_APP_STATE_REMOVING)) {
+               g_warning ("repo %s in invalid state %s",
+                          gs_app_get_id (app),
+                          as_app_state_to_string (state));
+               return;
+       }
 
        row = gs_repos_dialog_row_new ();
        gs_repos_dialog_row_set_name (GS_REPOS_DIALOG_ROW (row),


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