[polari] chatView: Always dispose cairo context



commit 96e41c0aad07942f8b8f6d1ad97a82c1999eb1c1
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jul 30 03:14:54 2015 +0200

    chatView: Always dispose cairo context
    
    Cairo contexts don't play well with SpiderMonkey's GC, and thus need to
    be disposed explicitly. However we are currently not doing that when
    returning early from ::draw, piling up resources in turn.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733327

 src/chatView.js |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index e64fe03..a3ea51a 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -56,8 +56,10 @@ const TextView = new Lang.Class({
         this.parent(cr);
 
         let mark = this.buffer.get_mark('indicator-line');
-        if (!mark)
+        if (!mark) {
+            cr.$dispose();
             return Gdk.EVENT_PROPAGATE;
+        }
 
         let iter = this.buffer.get_iter_at_mark(mark);
         let location = this.get_iter_location(iter);
@@ -68,17 +70,15 @@ const TextView = new Lang.Class({
                          this.get_pixels_below_lines(this)) / 2;
 
         let [hasClip, clip] = Gdk.cairo_get_clip_rectangle(cr);
-        if (!hasClip)
-            return Gdk.EVENT_PROPAGATE;
-
-        if (clip.y > y - lineSpace + 1 ||
-            clip.y + clip.height < y - lineSpace)
-            return Gdk.EVENT_PROPAGATE;
-
-        Gdk.cairo_set_source_rgba(cr, this._dimColor);
-        cr.rectangle(MARGIN, y - lineSpace,
-                     this.get_allocated_width() - 2 * MARGIN, 1);
-        cr.fill();
+        if (hasClip &&
+            clip.y <= y - lineSpace &&
+            clip.y + clip.height >= y - lineSpace + 1) {
+
+            Gdk.cairo_set_source_rgba(cr, this._dimColor);
+            cr.rectangle(MARGIN, y - lineSpace,
+                         this.get_allocated_width() - 2 * MARGIN, 1);
+            cr.fill();
+        }
         cr.$dispose();
 
         return Gdk.EVENT_PROPAGATE;


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