[gnome-builder] highlight: be defensive about having highlighter/buffer



commit 920b95c0dc79cdbdc6656684776445ec7ff18b23
Author: Christian Hergert <christian hergert me>
Date:   Thu Mar 26 13:01:35 2015 -0700

    highlight: be defensive about having highlighter/buffer

 libide/ide-highlight-engine.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-highlight-engine.c b/libide/ide-highlight-engine.c
index 4cb38ef..3eb9339 100644
--- a/libide/ide-highlight-engine.c
+++ b/libide/ide-highlight-engine.c
@@ -230,7 +230,7 @@ ide_highlight_engine_queue_work (IdeHighlightEngine *self)
 {
   g_assert (IDE_IS_HIGHLIGHT_ENGINE (self));
 
-  if (self->work_timeout != 0)
+  if ((self->highlighter == NULL) || (self->buffer == NULL) || (self->work_timeout != 0))
     return;
 
   self->work_timeout = g_timeout_add (WORK_TIMEOUT_MSEC,
@@ -250,7 +250,13 @@ ide_highlight_engine_reload (IdeHighlightEngine *self)
 
   g_assert (IDE_IS_HIGHLIGHT_ENGINE (self));
 
-  if ((self->buffer == NULL) || (self->highlighter == NULL))
+  if (self->work_timeout != 0)
+    {
+      g_source_remove (self->work_timeout);
+      self->work_timeout = 0;
+    }
+
+  if (self->buffer == NULL)
     IDE_EXIT;
 
   buffer = GTK_TEXT_BUFFER (self->buffer);
@@ -270,6 +276,9 @@ ide_highlight_engine_reload (IdeHighlightEngine *self)
     if (self->tags [i] != NULL)
       gtk_text_buffer_remove_tag (buffer, self->tags [i], &begin, &end);
 
+  if (self->highlighter == NULL)
+    IDE_EXIT;
+
   ide_highlight_engine_queue_work (self);
 
   IDE_EXIT;


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