override rg2's gdkpixbuf.rotate with a noleak method instead of testing for the fix
[booh] / ext / rbbooh.c
index 56b101f..e64c403 100644 (file)
@@ -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);