[gtksourceview/wip/fix-search: 2/4] SearchContext: check return value of gtk_text_region_nth_subregion()



commit 5c50a33c840df07815be0a5dc51ea2cd06b8ed5f
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Mar 5 11:10:37 2015 +0100

    SearchContext: check return value of gtk_text_region_nth_subregion()
    
    If it returns FALSE, the iter is not set.

 gtksourceview/gtksourcesearchcontext.c |   60 ++++++++++++++++++++-----------
 1 files changed, 39 insertions(+), 21 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index 8195af8..c80c6a9 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -1592,15 +1592,21 @@ scan_all_region (GtkSourceSearchContext *search,
                return;
        }
 
-       gtk_text_region_nth_subregion (region_to_highlight,
-                                      0,
-                                      &start_search,
-                                      NULL);
+       if (!gtk_text_region_nth_subregion (region_to_highlight,
+                                           0,
+                                           &start_search,
+                                           NULL))
+       {
+               return;
+       }
 
-       gtk_text_region_nth_subregion (region_to_highlight,
-                                      nb_subregions - 1,
-                                      NULL,
-                                      &end_search);
+       if (!gtk_text_region_nth_subregion (region_to_highlight,
+                                           nb_subregions - 1,
+                                           NULL,
+                                           &end_search))
+       {
+               return;
+       }
 
        gtk_text_iter_order (&start_search, &end_search);
 
@@ -1790,15 +1796,21 @@ regex_search_handle_high_priority_region (GtkSourceSearchContext *search)
                return;
        }
 
-       gtk_text_region_nth_subregion (search->priv->high_priority_region,
-                                      0,
-                                      &start,
-                                      NULL);
+       if (!gtk_text_region_nth_subregion (search->priv->high_priority_region,
+                                           0,
+                                           &start,
+                                           NULL))
+       {
+               return;
+       }
 
-       gtk_text_region_nth_subregion (search->priv->high_priority_region,
-                                      nb_subregions - 1,
-                                      NULL,
-                                      &end);
+       if (!gtk_text_region_nth_subregion (search->priv->high_priority_region,
+                                           nb_subregions - 1,
+                                           NULL,
+                                           &end))
+       {
+               return;
+       }
 
        region = gtk_text_region_intersect (search->priv->scan_region,
                                            &start,
@@ -2026,7 +2038,10 @@ regex_search_scan_next_chunk (GtkSourceSearchContext *search)
                return;
        }
 
-       gtk_text_region_nth_subregion (search->priv->scan_region, 0, &chunk_start, NULL);
+       if (!gtk_text_region_nth_subregion (search->priv->scan_region, 0, &chunk_start, NULL))
+       {
+               return;
+       }
 
        chunk_end = chunk_start;
        gtk_text_iter_forward_lines (&chunk_end, SCAN_BATCH_SIZE);
@@ -3771,10 +3786,13 @@ _gtk_source_search_context_update_highlight (GtkSourceSearchContext *search,
        {
                GtkTextIter start;
 
-               gtk_text_region_nth_subregion (search->priv->scan_region,
-                                              0,
-                                              &start,
-                                              NULL);
+               if (!gtk_text_region_nth_subregion (search->priv->scan_region,
+                                                   0,
+                                                   &start,
+                                                   NULL))
+               {
+                       return;
+               }
 
                regex_search_scan_chunk (search, &start, end);
        }


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