[gtksourceview/gnome-3-14] Add bool return value for gtk_text_region_iterator_get_subregion()



commit 94f5902441c7f8b035588f8e440bc0a8c2b087b1
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Mar 5 11:21:20 2015 +0100

    Add bool return value for gtk_text_region_iterator_get_subregion()
    
    It'll make the code more robust if the buffer is destroyed (since the
    TextRegion has only a weak ref to the buffer).

 gtksourceview/gtktextregion.c |   23 +++++++++++++++--------
 gtksourceview/gtktextregion.h |    2 +-
 2 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/gtktextregion.c b/gtksourceview/gtktextregion.c
index bb4e844..e47b370 100644
--- a/gtksourceview/gtktextregion.c
+++ b/gtksourceview/gtktextregion.c
@@ -624,7 +624,7 @@ gtk_text_region_iterator_next (GtkTextRegionIterator *iter)
        }
 }
 
-void
+gboolean
 gtk_text_region_iterator_get_subregion (GtkTextRegionIterator *iter,
                                        GtkTextIter           *start,
                                        GtkTextIter           *end)
@@ -632,24 +632,31 @@ gtk_text_region_iterator_get_subregion (GtkTextRegionIterator *iter,
        GtkTextRegionIteratorReal *real;
        Subregion *sr;
 
-       g_return_if_fail (iter != NULL);
+       g_return_val_if_fail (iter != NULL, FALSE);
 
        real = (GtkTextRegionIteratorReal *)iter;
-       g_return_if_fail (check_iterator (real));
-       g_return_if_fail (real->subregions != NULL);
+       g_return_val_if_fail (check_iterator (real), FALSE);
+       g_return_val_if_fail (real->subregions != NULL, FALSE);
 
        if (real->region->buffer == NULL)
        {
-               return;
+               return FALSE;
        }
 
        sr = (Subregion*)real->subregions->data;
-       g_return_if_fail (sr != NULL);
+       g_return_val_if_fail (sr != NULL, FALSE);
 
-       if (start)
+       if (start != NULL)
+       {
                gtk_text_buffer_get_iter_at_mark (real->region->buffer, start, sr->start);
-       if (end)
+       }
+
+       if (end != NULL)
+       {
                gtk_text_buffer_get_iter_at_mark (real->region->buffer, end, sr->end);
+       }
+
+       return TRUE;
 }
 
 void
diff --git a/gtksourceview/gtktextregion.h b/gtksourceview/gtktextregion.h
index c422633..b830f0e 100644
--- a/gtksourceview/gtktextregion.h
+++ b/gtksourceview/gtktextregion.h
@@ -86,7 +86,7 @@ G_GNUC_INTERNAL
 gboolean       gtk_text_region_iterator_next               (GtkTextRegionIterator *iter);
 
 G_GNUC_INTERNAL
-void           gtk_text_region_iterator_get_subregion       (GtkTextRegionIterator *iter,
+gboolean       gtk_text_region_iterator_get_subregion       (GtkTextRegionIterator *iter,
                                                             GtkTextIter           *start,
                                                             GtkTextIter           *end);
 


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