Blame SOURCES/0001-Fix-leaks-of-Pango-objects.patch

a8326b
From eca72baa5616fbe4dbebea43c7e5940847dc5ab8 Mon Sep 17 00:00:00 2001
a8326b
From: "Owen W. Taylor" <otaylor@fishsoup.net>
a8326b
Date: Tue, 27 Sep 2011 00:17:52 -0400
a8326b
Subject: [PATCH 1/2] Fix leaks of Pango objects
a8326b
a8326b
Gtk.PrintContext.create_pango_context()
a8326b
Gtk.PrintContext.create_pango_layout()
a8326b
pangocairo.CairoContext.create_layout()
a8326b
a8326b
were leaking the objects they returned.
a8326b
a8326b
https://bugzilla.gnome.org/show_bug.cgi?id=660216
a8326b
---
a8326b
 gtk/gtk-2.10.defs   |  2 ++
a8326b
 pangocairo.override | 11 ++++++++---
a8326b
 2 files changed, 10 insertions(+), 3 deletions(-)
a8326b
a8326b
diff --git a/gtk/gtk-2.10.defs b/gtk/gtk-2.10.defs
a8326b
index 69c7e0c..faa45e1 100644
a8326b
--- a/gtk/gtk-2.10.defs
a8326b
+++ b/gtk/gtk-2.10.defs
a8326b
@@ -1388,12 +1388,14 @@
a8326b
 (define-method create_pango_context
a8326b
   (of-object "GtkPrintContext")
a8326b
   (c-name "gtk_print_context_create_pango_context")
a8326b
+  (caller-owns-return #t)
a8326b
   (return-type "PangoContext*")
a8326b
 )
a8326b
 
a8326b
 (define-method create_pango_layout
a8326b
   (of-object "GtkPrintContext")
a8326b
   (c-name "gtk_print_context_create_pango_layout")
a8326b
+  (caller-owns-return #t)
a8326b
   (return-type "PangoLayout*")
a8326b
 )
a8326b
 
a8326b
diff --git a/pangocairo.override b/pangocairo.override
a8326b
index bb923e6..5101107 100644
a8326b
--- a/pangocairo.override
a8326b
+++ b/pangocairo.override
a8326b
@@ -118,11 +118,16 @@ _wrap_pango_cairo_update_context(PyGObject *self, PyObject *args, PyObject *kwar
a8326b
 static PyObject *
a8326b
 _wrap_pango_cairo_create_layout(PyGObject *self)
a8326b
 {
a8326b
-    PangoLayout *ret;
a8326b
+    PangoLayout *layout;
a8326b
+    PyObject *ret;
a8326b
 
a8326b
-    ret = pango_cairo_create_layout(PycairoContext_GET(self));
a8326b
+    layout = pango_cairo_create_layout(PycairoContext_GET(self));
a8326b
     /* pygobject_new handles NULL checking */
a8326b
-    return pygobject_new((GObject *)ret);
a8326b
+    ret = pygobject_new((GObject *)layout);
a8326b
+    if (layout)
a8326b
+	g_object_unref(layout);
a8326b
+
a8326b
+    return ret;
a8326b
 }
a8326b
 
a8326b
 static PyObject *
a8326b
-- 
a8326b
2.5.5
a8326b