From 37a080b5765c6ed5d159253c3fe1ede992c5183a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Fernandes?= Date: Fri, 20 Oct 2017 00:36:10 +0000 Subject: list-view: Don't try to get fts snippet for dummy row If org.gnome.nautilus.list-view use-tree-view is TRUE, folders can be expanded, which creates a dummy row to display the "Loading" label. When displaying search results as a list, we look for the fts_snippet on every row's NautilusFile, but this causes a crash when a dummy row is created, because its NautilusFile is NULL. Therefore, we should not look for fts_snippet on dummy rows. Fixes: https://gitlab.gnome.org/GNOME/nautilus/issues/54 (cherry picked from commit 0a67e3d5bbb283228d5daf576d63fb7847009cce) --- src/nautilus-list-view.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index 759e3b158..dc2280c74 100644 --- a/src/nautilus-list-view.c +++ b/src/nautilus-list-view.c @@ -1611,24 +1611,27 @@ filename_cell_data_func (GtkTreeViewColumn *column, NAUTILUS_LIST_MODEL_FILE_COLUMN, &file, -1); - snippet = nautilus_file_get_search_fts_snippet (file); - if (snippet) + /* Rule out dummy row */ + if (file != NULL) { - replaced_text = g_regex_replace (view->details->regex, - snippet, - -1, - 0, - " ", - G_REGEX_MATCH_NEWLINE_ANY, - NULL); + snippet = nautilus_file_get_search_fts_snippet (file); + if (snippet) + { + replaced_text = g_regex_replace (view->details->regex, + snippet, + -1, + 0, + " ", + G_REGEX_MATCH_NEWLINE_ANY, + NULL); - escaped_text = g_markup_escape_text (replaced_text, -1); + escaped_text = g_markup_escape_text (replaced_text, -1); - g_string_append_printf (display_text, - " %s", - escaped_text); + g_string_append_printf (display_text, + " %s", + escaped_text); + } } - nautilus_file_unref (file); } -- cgit v1.2.1