[mingw-gtk2] add patch for 16bpp gdk memory leak

sailer sailer at fedoraproject.org
Tue Feb 11 10:13:07 UTC 2014


commit 17b829fee54aee357084453e68c7b5a584636016
Author: Thomas Sailer <t.sailer at alumni.ethz.ch>
Date:   Tue Feb 11 11:13:32 2014 +0100

    add patch for 16bpp gdk memory leak

 gnomebug671538.patch |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++
 mingw-gtk2.spec      |   12 ++++++++++-
 2 files changed, 65 insertions(+), 1 deletions(-)
---
diff --git a/gnomebug671538.patch b/gnomebug671538.patch
new file mode 100644
index 0000000..ea07420
--- /dev/null
+++ b/gnomebug671538.patch
@@ -0,0 +1,54 @@
+From 7aa624ba01a89c23e25d7d67b3fd54b4a9ae4084 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau at gmail.com>
+Date: Mon, 8 Apr 2013 22:45:50 +0200
+Subject: [PATCH] win32: free allocated gdi objects in 16bpp
+
+In 16bpp, Gdk is creating hbitmap with CreateDIBSection() and a hdc with
+CreateCompatibleDC(). Those 2 objects need to be released when the
+pixmap is finalized.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=671538
+---
+ gdk/win32/gdkpixmap-win32.c | 7 +++++++
+ gdk/win32/gdkpixmap-win32.h | 1 +
+ 2 files changed, 8 insertions(+)
+
+diff --git a/gdk/win32/gdkpixmap-win32.c b/gdk/win32/gdkpixmap-win32.c
+index 6d18ca4..53c6f3c 100644
+--- a/gdk/win32/gdkpixmap-win32.c
++++ b/gdk/win32/gdkpixmap-win32.c
+@@ -121,6 +121,11 @@ gdk_pixmap_impl_win32_finalize (GObject *object)
+       /* Drop our reference */
+       cairo_surface_destroy (drawable_impl->cairo_surface);
+       drawable_impl->cairo_surface = NULL;
++
++      if (impl->is_allocated) {
++          GDI_CALL (DeleteDC, (drawable_impl->hdc));
++          DeleteObject (GDK_PIXMAP_HBITMAP (wrapper));
++      }
+     }
+ 
+   _gdk_win32_drawable_finish (GDK_DRAWABLE (object));
+@@ -264,6 +269,8 @@ _gdk_pixmap_new (GdkDrawable *drawable,
+       HWND hwnd;
+       GdkVisual *visual;
+ 
++      pixmap_impl->is_allocated = TRUE;
++
+       if (GDK_IS_WINDOW (drawable))
+ 	hwnd = GDK_WINDOW_HWND (drawable);
+       else
+diff --git a/gdk/win32/gdkpixmap-win32.h b/gdk/win32/gdkpixmap-win32.h
+index fbeb28f..e9d965d 100644
+--- a/gdk/win32/gdkpixmap-win32.h
++++ b/gdk/win32/gdkpixmap-win32.h
+@@ -53,6 +53,7 @@ struct _GdkPixmapImplWin32
+   gint height;
+   guchar *bits;
+   guint is_foreign : 1;
++  guint is_allocated : 1;
+ };
+  
+ struct _GdkPixmapImplWin32Class 
+-- 
+1.8.1.1.439.g50a6b54
\ No newline at end of file
diff --git a/mingw-gtk2.spec b/mingw-gtk2.spec
index 1402354..2c5a75f 100644
--- a/mingw-gtk2.spec
+++ b/mingw-gtk2.spec
@@ -2,7 +2,7 @@
 
 Name:           mingw-gtk2
 Version:        2.24.22
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        MinGW Windows Gtk2 library
 
 License:        LGPLv2+
@@ -26,6 +26,12 @@ Patch15:        window-dragging.patch
 # https://bugzilla.gnome.org/show_bug.cgi?id=704508
 Patch17:        gtk-combo-box-dont-use-invalidated-iter.patch
 
+# Don't leak memory with 16bpp
+# https://bugzilla.redhat.com/show_bug.cgi?id=1063709
+# https://bugzilla.gnome.org/show_bug.cgi?id=671538
+# https://bug671538.bugzilla-attachments.gnome.org/attachment.cgi?id=240982
+Patch18:        gnomebug671538.patch
+
 # Fix use of extended buttons in gtkstatusicon.
 Patch1000:      mingw32-gtk2-2.15.0-xbuttons.patch
 
@@ -128,6 +134,7 @@ Static version of the MinGW Windows Gtk2 library.
 %patch8 -p1 -b .tooltip-positioning
 %patch15 -p1 -b .window-dragging
 %patch17 -p1 -b .combobox_iter
+%patch18 -p0 -b .16bpp
 
 %patch1000 -p1
 autoreconf -i --force
@@ -317,6 +324,9 @@ rm -f $RPM_BUILD_ROOT%{mingw64_libdir}/gtk-2.0/modules/*.dll.a
 
 
 %changelog
+* Tue Feb 11 2014 Thomas Sailer <t.sailer at alumni.ethz.ch> - 2.24.22-2
+- Patch for Gdk 16bpp memory leak
+
 * Sun Oct 13 2013 Erik van Pienbroek <epienbro at fedoraproject.org> - 2.24.22-1
 - Update to 2.24.22
 


More information about the scm-commits mailing list