[gnome-software] Fix an assert when a codec is not found
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Fix an assert when a codec is not found
- Date: Mon, 17 Oct 2016 09:08:52 +0000 (UTC)
commit d068f3a94fdd2ac30913be51f1ec7d8c4d5f81b3
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
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 1671c62..d38d5cc 100644
--- a/src/gs-shell-extras.c
+++ b/src/gs-shell-extras.c
@@ -526,28 +526,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, GS_PLUGIN_ERROR, GS_PLUGIN_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++) {
@@ -624,28 +621,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, GS_PLUGIN_ERROR, GS_PLUGIN_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]