[gtk+/gtk-2-24] win32: Don't leak the pixmap cairo_surface
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] win32: Don't leak the pixmap cairo_surface
- Date: Wed, 24 Oct 2012 10:44:17 +0000 (UTC)
commit bb867e9406ee0d9e6109bfc4c33a38585c76a242
Author: Alexander Larsson <alexl redhat com>
Date: Mon Oct 22 20:51:17 2012 +0200
win32: Don't leak the pixmap cairo_surface
GdkPixmapWin32 allocates a cairo_surface manually for non-foreign
pixmaps, instead of letting GdkDrawableWin32 create on on-demand.
However, the pixmap created surface is a strong ref, rather than the
weak ref created by gdk_win32_ref_cairo_surface() so we can't rely
on _gdk_win32_drawable_finish to actually free it. So, we have to
manually free it when we finalize or we leak it.
https://bugzilla.gnome.org/show_bug.cgi?id=685959
gdk/win32/gdkpixmap-win32.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gdk/win32/gdkpixmap-win32.c b/gdk/win32/gdkpixmap-win32.c
index e803877..bb4718c 100644
--- a/gdk/win32/gdkpixmap-win32.c
+++ b/gdk/win32/gdkpixmap-win32.c
@@ -105,13 +105,23 @@ static void
gdk_pixmap_impl_win32_finalize (GObject *object)
{
GdkPixmapImplWin32 *impl = GDK_PIXMAP_IMPL_WIN32 (object);
- GdkPixmap *wrapper = GDK_PIXMAP (GDK_DRAWABLE_IMPL_WIN32 (impl)->wrapper);
+ GdkDrawableImplWin32 *drawable_impl = GDK_DRAWABLE_IMPL_WIN32 (impl);
+ GdkPixmap *wrapper = GDK_PIXMAP (drawable_impl->wrapper);
GDK_NOTE (PIXMAP, g_print ("gdk_pixmap_impl_win32_finalize: %p\n",
GDK_PIXMAP_HBITMAP (wrapper)));
if (!impl->is_foreign)
- GDK_DRAWABLE_IMPL_WIN32 (impl)->hdc_count--;
+ {
+ drawable_impl->hdc_count--;
+
+ /* Tell outstanding owners that the surface is useless */
+ cairo_surface_finish (drawable_impl->cairo_surface);
+
+ /* Drop our reference */
+ cairo_surface_destroy (drawable_impl->cairo_surface);
+ drawable_impl->cairo_surface = NULL;
+ }
_gdk_win32_drawable_finish (GDK_DRAWABLE (object));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]