From 6d797d5356cf7af445befb846e260b92e6cece2c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 28 Aug 2011 22:43:20 -0400 Subject: [PATCH] GtkAppChooser: Deal with 'no app found' gracefully Several functions inside GtkAppChooserDialog were not handling the situation that app_info might be NULL after the user clicked 'Select'. https://bugzilla.gnome.org/show_bug.cgi?id=651827 --- gtk/gtkappchooserdialog.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/gtk/gtkappchooserdialog.c b/gtk/gtkappchooserdialog.c index 5f0de03766..178d291e20 100644 --- a/gtk/gtkappchooserdialog.c +++ b/gtk/gtkappchooserdialog.c @@ -212,6 +212,12 @@ check_application (GtkAppChooserDialog *self, command = NULL; info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->priv->app_chooser_widget)); + if (info == NULL) + { + *app_out = NULL; + return FALSE; + } + command = g_app_info_get_executable (info); g_shell_parse_argv (command, &argc, &argv, &error); @@ -258,13 +264,15 @@ add_or_find_application (GtkAppChooserDialog *self) app = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self)); - /* we don't care about reporting errors here */ - if (self->priv->content_type) - g_app_info_set_as_last_used_for_type (app, - self->priv->content_type, - NULL); - - g_object_unref (app); + if (app) + { + /* we don't care about reporting errors here */ + if (self->priv->content_type) + g_app_info_set_as_last_used_for_type (app, + self->priv->content_type, + NULL); + g_object_unref (app); + } } static void