0001-Fix-leaks-of-Pango-objects.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From eca72baa5616fbe4dbebea43c7e5940847dc5ab8 Mon Sep 17 00:00:00 2001
  2. From: "Owen W. Taylor" <otaylor@fishsoup.net>
  3. Date: Tue, 27 Sep 2011 00:17:52 -0400
  4. Subject: [PATCH 1/2] Fix leaks of Pango objects
  5. Gtk.PrintContext.create_pango_context()
  6. Gtk.PrintContext.create_pango_layout()
  7. pangocairo.CairoContext.create_layout()
  8. were leaking the objects they returned.
  9. https://bugzilla.gnome.org/show_bug.cgi?id=660216
  10. ---
  11. gtk/gtk-2.10.defs | 2 ++
  12. pangocairo.override | 11 ++++++++---
  13. 2 files changed, 10 insertions(+), 3 deletions(-)
  14. diff --git a/gtk/gtk-2.10.defs b/gtk/gtk-2.10.defs
  15. index 69c7e0c..faa45e1 100644
  16. --- a/gtk/gtk-2.10.defs
  17. +++ b/gtk/gtk-2.10.defs
  18. @@ -1388,12 +1388,14 @@
  19. (define-method create_pango_context
  20. (of-object "GtkPrintContext")
  21. (c-name "gtk_print_context_create_pango_context")
  22. + (caller-owns-return #t)
  23. (return-type "PangoContext*")
  24. )
  25. (define-method create_pango_layout
  26. (of-object "GtkPrintContext")
  27. (c-name "gtk_print_context_create_pango_layout")
  28. + (caller-owns-return #t)
  29. (return-type "PangoLayout*")
  30. )
  31. diff --git a/pangocairo.override b/pangocairo.override
  32. index bb923e6..5101107 100644
  33. --- a/pangocairo.override
  34. +++ b/pangocairo.override
  35. @@ -118,11 +118,16 @@ _wrap_pango_cairo_update_context(PyGObject *self, PyObject *args, PyObject *kwar
  36. static PyObject *
  37. _wrap_pango_cairo_create_layout(PyGObject *self)
  38. {
  39. - PangoLayout *ret;
  40. + PangoLayout *layout;
  41. + PyObject *ret;
  42. - ret = pango_cairo_create_layout(PycairoContext_GET(self));
  43. + layout = pango_cairo_create_layout(PycairoContext_GET(self));
  44. /* pygobject_new handles NULL checking */
  45. - return pygobject_new((GObject *)ret);
  46. + ret = pygobject_new((GObject *)layout);
  47. + if (layout)
  48. + g_object_unref(layout);
  49. +
  50. + return ret;
  51. }
  52. static PyObject *
  53. --
  54. 2.5.5