[gtksourceview/wip/search-weak-ref] SearchContext: clear search when buffer destroyed (!doesn't work)
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/search-weak-ref] SearchContext: clear search when buffer destroyed (!doesn't work)
- Date: Thu, 5 Mar 2015 14:33:54 +0000 (UTC)
commit 1cab23a3029336fea2b27d459325059735248ff8
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu Mar 5 15:32:08 2015 +0100
SearchContext: clear search when buffer destroyed (!doesn't work)
So the idle scan function is removed.
But there is a bug in GObject, the unit test fails.
See https://bugzilla.gnome.org/show_bug.cgi?id=745678
gtksourceview/gtksourcesearchcontext.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index 2a47945..4273315 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -2111,13 +2111,6 @@ 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);
@@ -2535,6 +2528,14 @@ delete_range_after_cb (GtkSourceSearchContext *search,
}
static void
+buffer_destroyed_cb (GtkSourceSearchContext *search,
+ GObject *where_the_object_was)
+{
+ search->priv->buffer = NULL;
+ clear_search (search);
+}
+
+static void
set_buffer (GtkSourceSearchContext *search,
GtkSourceBuffer *buffer)
{
@@ -2543,8 +2544,9 @@ set_buffer (GtkSourceSearchContext *search,
search->priv->buffer = GTK_TEXT_BUFFER (buffer);
- g_object_add_weak_pointer (G_OBJECT (buffer),
- (gpointer *)&search->priv->buffer);
+ g_object_weak_ref (G_OBJECT (buffer),
+ (GWeakNotify) buffer_destroyed_cb,
+ search);
search->priv->tag_table = gtk_text_buffer_get_tag_table (search->priv->buffer);
g_object_ref (search->priv->tag_table);
@@ -2671,8 +2673,9 @@ gtk_source_search_context_dispose (GObject *object)
if (search->priv->buffer != NULL)
{
- g_object_remove_weak_pointer (G_OBJECT (search->priv->buffer),
- (gpointer *)&search->priv->buffer);
+ g_object_weak_unref (G_OBJECT (search->priv->buffer),
+ (GWeakNotify) buffer_destroyed_cb,
+ search);
search->priv->buffer = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]