[gtksourceview] search: block callbacks during replace all



commit 3c2dd9d8293f2b02108751cf053bf030f3b59999
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Tue Jul 9 12:15:19 2013 +0200

    search: block callbacks during replace all
    
    There is a big difference in performances.

 gtksourceview/gtksourcesearch.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearch.c b/gtksourceview/gtksourcesearch.c
index c512083..f1a190e 100644
--- a/gtksourceview/gtksourcesearch.c
+++ b/gtksourceview/gtksourcesearch.c
@@ -2106,6 +2106,11 @@ _gtk_source_search_replace_all (GtkSourceSearch *search,
                return 0;
        }
 
+       g_signal_handlers_block_by_func (search->priv->buffer, insert_text_before_cb, search);
+       g_signal_handlers_block_by_func (search->priv->buffer, insert_text_after_cb, search);
+       g_signal_handlers_block_by_func (search->priv->buffer, delete_range_before_cb, search);
+       g_signal_handlers_block_by_func (search->priv->buffer, delete_range_after_cb, search);
+
        gtk_text_buffer_get_start_iter (search->priv->buffer, &iter);
 
        gtk_text_buffer_begin_user_action (search->priv->buffer);
@@ -2121,5 +2126,12 @@ _gtk_source_search_replace_all (GtkSourceSearch *search,
 
        gtk_text_buffer_end_user_action (search->priv->buffer);
 
+       g_signal_handlers_unblock_by_func (search->priv->buffer, insert_text_before_cb, search);
+       g_signal_handlers_unblock_by_func (search->priv->buffer, insert_text_after_cb, search);
+       g_signal_handlers_unblock_by_func (search->priv->buffer, delete_range_before_cb, search);
+       g_signal_handlers_unblock_by_func (search->priv->buffer, delete_range_after_cb, search);
+
+       update (search);
+
        return nb_matches_replaced;
 }


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