From d2fe45ab5754fa4fdb437516cabf02dec5eb5593 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 2 Mar 2015 15:38:29 -0500 Subject: [PATCH] file chooser: Avoid warnings from the location column Avoid criticals that would come out of this code if file is / or NULL. --- gtk/gtkfilechooserwidget.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index bd39b8d8ef..0f39ca2ed9 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -4066,11 +4066,14 @@ file_system_model_set (GtkFileSystemModel *model, gchar *location; home_location = g_file_new_for_path (g_get_home_dir ()); - dir_location = g_file_get_parent (file); + if (file) + dir_location = g_file_get_parent (file); + else + dir_location = NULL; - if (g_file_equal (home_location, dir_location)) + if (dir_location && g_file_equal (home_location, dir_location)) location = g_strdup (_("Home")); - else if (g_file_has_prefix (dir_location, home_location)) + else if (dir_location && g_file_has_prefix (dir_location, home_location)) { gchar *relative_path; @@ -4084,7 +4087,8 @@ file_system_model_set (GtkFileSystemModel *model, g_value_take_string (value, location); - g_object_unref (dir_location); + if (dir_location) + g_object_unref (dir_location); g_object_unref (home_location); } break;