summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorP. F. Chimento <philip.chimento@gmail.com>2013-11-15 14:07:29 -0800
committerP. F. Chimento <philip.chimento@gmail.com>2013-11-15 14:07:29 -0800
commitc05566dadc0ccbbde7d0e44f477ba272adfd073c (patch)
treecaafab6a31b399c5a214a2f51b35180ccc3580eb
parenta18690dc897ea81adfb68ab41f77e088069583dd (diff)
parent32f9ad139a40f86e20feb9f06f98782c90d21b11 (diff)
Merge pull request #404 from endlessm/issues/403
#403 better fix for memory leak
-rw-r--r--wikipedia/widgets/category_button.js33
1 files changed, 15 insertions, 18 deletions
diff --git a/wikipedia/widgets/category_button.js b/wikipedia/widgets/category_button.js
index 81f3dea..667a816 100644
--- a/wikipedia/widgets/category_button.js
+++ b/wikipedia/widgets/category_button.js
@@ -63,7 +63,6 @@ const CategoryButton = new Lang.Class({
this._is_main_category = null;
this._pixbuf = null;
- this._overlay = new Gtk.Overlay();
this._eventbox = new Gtk.EventBox({
expand: true
});
@@ -95,22 +94,15 @@ const CategoryButton = new Lang.Class({
context.add_class(EndlessWikipedia.STYLE_CLASS_TITLE);
context.add_class(EndlessWikipedia.STYLE_CLASS_CATEGORY);
context.add_class(EndlessWikipedia.STYLE_CLASS_FRONT_PAGE);
- this._image = new Gtk.Image({
- expand: true,
- halign: Gtk.Align.FILL,
- valign: Gtk.Align.FILL
- });
// Parent constructor sets all properties
this.parent(props);
// Put widgets together
- this.add(this._overlay);
- this._overlay.add(this._image);
this._eventbox_grid.add(this._label);
this._eventbox_grid.add(this._arrow);
this._eventbox.add(this._eventbox_grid);
- this._overlay.add_overlay(this._eventbox);
+ this.add(this._eventbox);
this.show_all();
// Connect signals
@@ -124,7 +116,6 @@ const CategoryButton = new Lang.Class({
set image_uri(value) {
this._image_uri = value;
- this._update_pixbuf();
},
get category_title() {
@@ -189,23 +180,29 @@ const CategoryButton = new Lang.Class({
}
},
- vfunc_size_allocate: function(allocation) {
- this.parent(allocation);
- this._update_pixbuf();
- },
-
// Reloads the pixbuf from the gresource at the proper size if necessary
_update_pixbuf: function () {
if (this._image_uri === "" || this._image_uri === null)
return;
let allocation = this.get_allocation();
- if (allocation.width <= 1 || allocation.height <= 1)
- return;
if (this._pixbuf === null || this._pixbuf.get_width() !== allocation.width ||
this._pixbuf.get_height() !== allocation.height)
this._pixbuf = Utils.load_pixbuf_cover(Utils.resourceUriToPath(this._image_uri),
allocation.width, allocation.height);
- this._image.set_from_pixbuf(this._pixbuf);
+ },
+
+ vfunc_draw: function (cr) {
+ this._update_pixbuf();
+ if (this._pixbuf !== null) {
+ Gdk.cairo_set_source_pixbuf(cr, this._pixbuf, 0, 0);
+ cr.paint();
+ }
+ let ret = this.parent(cr);
+ // We need to manually call dispose on cairo contexts. This is somewhat related to the bug listed here
+ // https://bugzilla.gnome.org/show_bug.cgi?id=685513 for the shell. We should see if they come up with
+ // a better fix in the future, i.e. fix this through gjs.
+ cr.$dispose();
+ return ret;
},
// HANDLERS