[gnome-logs] Fix crash when exact search type is selected



commit 47e83b70d8248629cc47c66d08f062d9c94c2f62
Author: Pranav Ganorkar <pranavg189 gmail com>
Date:   Sat Jan 28 23:43:08 2017 +0530

    Fix crash when exact search type is selected
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777681

 src/gl-journal-model.c |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/src/gl-journal-model.c b/src/gl-journal-model.c
index 0f3b8f5..165315f 100644
--- a/src/gl-journal-model.c
+++ b/src/gl-journal-model.c
@@ -395,9 +395,6 @@ void
 gl_journal_model_take_query (GlJournalModel *model,
                              GlQuery *query)
 {
-    GlQueryItem *search_match;
-    GPtrArray *search_matches;
-
     g_return_if_fail (GL_JOURNAL_MODEL (model));
 
     gl_journal_model_stop_idle (model);
@@ -421,20 +418,30 @@ gl_journal_model_take_query (GlJournalModel *model,
     /* Set new query */
     model->query = query;
 
-    search_matches = gl_query_get_substring_matches (model->query);
+    /* Tokenize the entered input only if search type is substring */
+    if (query->search_type == GL_QUERY_SEARCH_TYPE_SUBSTRING)
+    {
+        GlQueryItem *search_match;
+        GPtrArray *search_matches;
 
-    /* Get search text from a search match */
-    search_match = g_ptr_array_index (search_matches, 0);
+        search_matches = gl_query_get_substring_matches (model->query);
+
+        /* Get search text from a search match */
+        search_match = g_ptr_array_index (search_matches, 0);
+
+        if (search_match->field_value != NULL)
+        {
+            model->token_array = tokenize_search_string (search_match->field_value);
+        }
+
+         g_ptr_array_free (search_matches, TRUE);
 
-    if (search_match->field_value != NULL)
-    {
-        model->token_array = tokenize_search_string (search_match->field_value);
     }
 
     /* Start processing the new query */
     gl_journal_model_process_query (model);
 
-    g_ptr_array_free (search_matches, TRUE);
+
 }
 
 /* Add a new queryitem to query */


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