[gnome-software] overview: Improve error handling when featured apps loading fails



commit 6246cd24c7030df5a295dbc9146a287eefec2bc8
Author: Kalev Lember <kalevlember gmail com>
Date:   Mon Jun 15 09:45:59 2015 +0200

    overview: Improve error handling when featured apps loading fails
    
    Move error handling after the filtering of the featured apps list, since
    the filtering can reduce the list to being empty.
    
    Also, while at this, make sure to return early in case of
    G_IO_ERROR_CANCELLED; this would either mean (a) that the page is
    reloading, and there's no reason to do any work, or (b) that we're in
    dispose, and all the template children are already NULL and we can't do
    anything else besides returning.

 src/gs-shell-overview.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index bf1b82f..558026a 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -248,19 +248,21 @@ gs_shell_overview_get_featured_cb (GObject *source_object,
        GsApp *app;
        _cleanup_error_free_ GError *error = NULL;
 
-       gs_container_remove_all (GTK_CONTAINER (priv->bin_featured));
-
        list = gs_plugin_loader_get_featured_finish (plugin_loader, res, &error);
-       gtk_widget_set_visible (priv->featured_heading, list != NULL);
-       if (list == NULL) {
-               if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
-                       g_warning ("failed to get featured apps: %s", error->message);
+       if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                goto out;
-       }
+
        /* Don't show apps from the category that's currently featured as the category of the day */
        gs_plugin_list_filter (&list, filter_category, priv->category_of_day);
        gs_plugin_list_randomize (&list);
 
+       gs_container_remove_all (GTK_CONTAINER (priv->bin_featured));
+       gtk_widget_set_visible (priv->featured_heading, list != NULL);
+       if (list == NULL) {
+               g_warning ("failed to get featured apps: %s", error ? error->message : "no apps to show");
+               goto out;
+       }
+
        /* at the moment, we only care about the first app */
        app = GS_APP (list->data);
        tile = gs_feature_tile_new (app);


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