[gtksourceview/wip/search: 12/36] search: fix bug with idle callback not called



commit 571854f06791b1821d5e1db8431ab726598fc309
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Jun 30 14:10:26 2013 +0200

    search: fix bug with idle callback not called

 gtksourceview/gtksourcesearch.c |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearch.c b/gtksourceview/gtksourcesearch.c
index fb189d1..43b2aa7 100644
--- a/gtksourceview/gtksourcesearch.c
+++ b/gtksourceview/gtksourcesearch.c
@@ -1123,8 +1123,6 @@ scan_task_region (GtkSourceSearch *search)
 static gboolean
 idle_scan_cb (GtkSourceSearch *search)
 {
-       gboolean finished = FALSE;
-
        if (search->priv->high_priority_region != NULL)
        {
                /* Normally the high priority region is not really big, since it
@@ -1135,19 +1133,29 @@ idle_scan_cb (GtkSourceSearch *search)
 
                gtk_text_region_destroy (search->priv->high_priority_region, TRUE);
                search->priv->high_priority_region = NULL;
+
+               return TRUE;
        }
-       else if (search->priv->task_region != NULL)
+
+       if (search->priv->task_region != NULL)
        {
+               /* Finish this idle, and install a new one, because
+                * scan_task_region() can also indirectly call
+                * install_idle_scan(). When install_idle_scan() is called
+                * indirectly, we must be sure that the idle function will be
+                * run.
+                */
+               search->priv->idle_scan_id = 0;
+               install_idle_scan (search);
+
                scan_task_region (search);
-       }
-       else
-       {
-               scan_region_forward (search, search->priv->scan_region);
+               return FALSE;
        }
 
+       scan_region_forward (search, search->priv->scan_region);
+
        if (is_text_region_empty (search->priv->scan_region))
        {
-               finished = TRUE;
                search->priv->idle_scan_id = 0;
 
                g_object_notify (G_OBJECT (search->priv->buffer), "search-occurrences-count");
@@ -1157,9 +1165,11 @@ idle_scan_cb (GtkSourceSearch *search)
                        gtk_text_region_destroy (search->priv->scan_region, TRUE);
                        search->priv->scan_region = NULL;
                }
+
+               return FALSE;
        }
 
-       return !finished;
+       return TRUE;
 }
 
 static void



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