[polari/gnome-3-16] chatView: Always dispose cairo context



commit 2a2d5938f0ad8cc50863c60a5863231341c0c3fb
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 bccbdb3..8e48623 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -54,8 +54,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);
@@ -66,17 +68,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]