[gtk+/gtk-2-24] win32: free allocated gdi objects in 16bpp



commit 95985a2181b49a92ec7b8f0eed0dd26052444d86
Author: Marc-André Lureau <marcandre lureau gmail com>
Date:   Mon Apr 8 22:45:50 2013 +0200

    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
    
    Signed-off-by: Hans Breuer <hans breuer org>

 gdk/win32/gdkpixmap-win32.c |    6 ++++++
 gdk/win32/gdkpixmap-win32.h |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gdk/win32/gdkpixmap-win32.c b/gdk/win32/gdkpixmap-win32.c
index e06d069..0c5251a 100644
--- a/gdk/win32/gdkpixmap-win32.c
+++ b/gdk/win32/gdkpixmap-win32.c
@@ -125,6 +125,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));
+             GDI_CALL (DeleteObject, (GDK_PIXMAP_HBITMAP (wrapper)));
+           }
        }
     }
 
@@ -321,6 +326,7 @@ _gdk_pixmap_new (GdkDrawable *drawable,
        }
 
       SelectObject (hdc, hbitmap);
+      pixmap_impl->is_allocated = TRUE;
     }
 
   /* We need to use the same hdc, because only one hdc
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 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]