[gtksourceview/gnome-3-14] SearchContext: clear search if buffer is destroyed



commit 335e463019b0ed2d10daf0b0e708407330995085
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Mar 5 14:19:52 2015 +0100

    SearchContext: clear search if buffer is destroyed
    
    Ideally we should call clear_search() (and thus removing the idle
    function) _when_ the buffer is destroyed, that is, in a GWeakNotify
    callback (i.e. use g_object_weak_ref() instead of
    g_object_add_weak_pointer() when setting the buffer). But there is a bug
    in GObject that prevents doing this, see:
    https://bugzilla.gnome.org/show_bug.cgi?id=745678

 gtksourceview/gtksourcesearchcontext.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index 7507b77..2e2d6db 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -2100,6 +2100,13 @@ idle_scan_regex_search (GtkSourceSearchContext *search)
 static gboolean
 idle_scan_cb (GtkSourceSearchContext *search)
 {
+       if (search->priv->buffer == NULL)
+       {
+               search->priv->idle_scan_id = 0;
+               clear_search (search);
+               return G_SOURCE_REMOVE;
+       }
+
        return gtk_source_search_settings_get_regex_enabled (search->priv->settings) ?
               idle_scan_regex_search (search) :
               idle_scan_normal_search (search);


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