[gtksourceview/gnome-3-14] SearchContext: check return value of gtk_text_region_nth_subregion()



commit 41f7e1dd23ce6abf83e106d70d4a1304ced829ee
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 9f90215..bc280ae 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -1581,15 +1581,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);
 
@@ -1779,15 +1785,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,
@@ -2015,7 +2027,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);
@@ -3682,10 +3697,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]