[nautilus/gnome-3-26] list-view: Don't try to get fts snippet for dummy row



commit 37a080b5765c6ed5d159253c3fe1ede992c5183a
Author: António Fernandes <antoniojpfernandes gmail com>
Date:   Fri Oct 20 00:36:10 2017 +0000

    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,
-                                    " <small><span color='grey'><b>%s</b></span></small>",
-                                    escaped_text);
+                g_string_append_printf (display_text,
+                                        " <small><span color='grey'><b>%s</b></span></small>",
+                                        escaped_text);
+            }
         }
-
         nautilus_file_unref (file);
     }
 


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