[gnome-software/gnome-3-22] Fix an assert when a codec is not found



commit 0c6b05b91261d7693340b4d6c81100d20a8efe0c
Author: Richard Hughes <richard hughsie com>
Date:   Mon Oct 17 10:03:22 2016 +0100

    Fix an assert when a codec is not found
    
    When we can't find any results we now return an empty list rather than an error.
    Handle this in the various places that look for codecs to prevent a crash.
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=772996
    
    (cherry picked from commit d068f3a94fdd2ac30913be51f1ec7d8c4d5f81b3)

 src/gs-shell-extras.c |   62 ++++++++++++++++++++++--------------------------
 1 files changed, 28 insertions(+), 34 deletions(-)
---
diff --git a/src/gs-shell-extras.c b/src/gs-shell-extras.c
index b379ffb..b4a6cdd 100644
--- a/src/gs-shell-extras.c
+++ b/src/gs-shell-extras.c
@@ -523,28 +523,25 @@ search_files_cb (GObject *source_object,
 
        list = gs_plugin_loader_search_finish (plugin_loader, res, &error);
        if (list == NULL) {
+               g_autofree gchar *str = NULL;
                if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        g_debug ("extras: search files cancelled");
                        return;
                }
-               if (g_error_matches (error,
-                                    GS_PLUGIN_ERROR,
-                                    GS_PLUGIN_ERROR_FAILED)) {
-                       GsApp *app;
-
-                       g_debug ("extras: no search result for %s, showing as missing", search_data->title);
-                       app = create_missing_app (search_data);
-                       gs_app_list_add (list, app);
-               } else {
-                       g_autofree gchar *str = NULL;
+               g_warning ("failed to find any search results: %s", error->message);
+               str = g_strdup_printf ("%s: %s", _("Failed to find any search results"), error->message);
+               gtk_label_set_label (GTK_LABEL (self->label_failed), str);
+               gs_shell_extras_set_state (self, GS_SHELL_EXTRAS_STATE_FAILED);
+               return;
+       }
 
-                       g_warning ("failed to find any search results: %s", error->message);
-                       str = g_strdup_printf ("%s: %s", _("Failed to find any search results"), 
error->message);
-                       gtk_label_set_label (GTK_LABEL (self->label_failed), str);
-                       gs_shell_extras_set_state (self,
-                                                   GS_SHELL_EXTRAS_STATE_FAILED);
-                       return;
-               }
+       /* add missing item */
+       if (gs_app_list_length (list) == 0) {
+               g_autoptr(GsApp) app = NULL;
+               g_debug ("extras: no search result for %s, showing as missing",
+                        search_data->title);
+               app = create_missing_app (search_data);
+               gs_app_list_add (list, app);
        }
 
        for (i = 0; i < gs_app_list_length (list); i++) {
@@ -621,28 +618,25 @@ get_search_what_provides_cb (GObject *source_object,
 
        list = gs_plugin_loader_search_what_provides_finish (plugin_loader, res, &error);
        if (list == NULL) {
+               g_autofree gchar *str = NULL;
                if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        g_debug ("extras: search what provides cancelled");
                        return;
                }
-               if (g_error_matches (error,
-                                    GS_PLUGIN_ERROR,
-                                    GS_PLUGIN_ERROR_FAILED)) {
-                       GsApp *app;
-
-                       g_debug ("extras: no search result for %s, showing as missing", search_data->title);
-                       app = create_missing_app (search_data);
-                       gs_app_list_add (list, app);
-               } else {
-                       g_autofree gchar *str = NULL;
+               g_warning ("failed to find any search results: %s", error->message);
+               str = g_strdup_printf ("%s: %s", _("Failed to find any search results"), error->message);
+               gtk_label_set_label (GTK_LABEL (self->label_failed), str);
+               gs_shell_extras_set_state (self, GS_SHELL_EXTRAS_STATE_FAILED);
+               return;
+       }
 
-                       g_warning ("failed to find any search results: %s", error->message);
-                       str = g_strdup_printf ("%s: %s", _("Failed to find any search results"), 
error->message);
-                       gtk_label_set_label (GTK_LABEL (self->label_failed), str);
-                       gs_shell_extras_set_state (self,
-                                                   GS_SHELL_EXTRAS_STATE_FAILED);
-                       return;
-               }
+       /* add missing item */
+       if (gs_app_list_length (list) == 0) {
+               g_autoptr(GsApp) app = NULL;
+               g_debug ("extras: no search result for %s, showing as missing",
+                        search_data->title);
+               app = create_missing_app (search_data);
+               gs_app_list_add (list, app);
        }
 
        for (i = 0; i < gs_app_list_length (list); i++) {


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