From c2a035fe55c4f4b2e3d717c6c8fdce53e224e6f4 Mon Sep 17 00:00:00 2001 From: gc Date: Sat, 21 Jul 2007 22:00:15 +0000 Subject: [PATCH] override rg2's gdkpixbuf.rotate with a noleak method instead of testing for the fix --- bin/booh-classifier | 13 ------------- ext/rbbooh.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/bin/booh-classifier b/bin/booh-classifier index 5d02353..9a329aa 100644 --- a/bin/booh-classifier +++ b/bin/booh-classifier @@ -1354,19 +1354,6 @@ read_config Gtk.init -#- Gdk::Pixbuf#rotate memory leak check (in ruby-gnome2 <= 0.16.0) -#pb = Gdk::Pixbuf.new("#{$FPATH}/images/logo.png") -#1.upto(5) { pb = pb.rotate(Gdk::Pixbuf::ROTATE_CLOCKWISE) } -#GC.start -#mem = get_mem -#1.upto(5) { pb = pb.rotate(Gdk::Pixbuf::ROTATE_CLOCKWISE) } -#GC.start -#mem2 = get_mem -#if mem2 != mem -# puts _("Gdk::Pixbuf#scale memory leak detected (this is normal with unpatched ruby-gnome2 <= 0.16.0). Application would slow down to a crawl, won't proceed.") -# exit 1 -#end - create_main_window check_config diff --git a/ext/rbbooh.c b/ext/rbbooh.c index 56b101f..e64c403 100644 --- a/ext/rbbooh.c +++ b/ext/rbbooh.c @@ -164,6 +164,15 @@ static VALUE draw_borders(VALUE self, VALUE pixbuf, VALUE x1, VALUE x2, VALUE ys return self; } +static VALUE rotate_noleak(VALUE self, VALUE angle) { + VALUE ret; + GdkPixbuf* dest = gdk_pixbuf_rotate_simple(_SELF(self), RVAL2GENUM(angle, GDK_TYPE_PIXBUF_ROTATION)); + if (dest == NULL) + return Qnil; + ret = GOBJ2RVAL(dest); + g_object_unref(dest); + return ret; +} void Init_libadds() @@ -171,6 +180,7 @@ Init_libadds() RGObjClassInfo* cinfo = (RGObjClassInfo*)rbgobj_lookup_class_by_gtype(GDK_TYPE_PIXBUF, Qnil); rb_define_method(cinfo->klass, "whitebalance!", whitebalance, 1); rb_define_method(cinfo->klass, "gammacorrect!", gammacorrect, 1); + rb_define_method(cinfo->klass, "rotate", rotate_noleak, 1); cinfo = (RGObjClassInfo*)rbgobj_lookup_class_by_gtype(GDK_TYPE_DRAWABLE, Qnil); rb_define_method(cinfo->klass, "draw_borders", draw_borders, 5); -- 2.21.3