From f3668e96e78d7a060f9affa8f6dc6fe15251c5b1 Mon Sep 17 00:00:00 2001 From: Hans Breuer Date: Sat, 18 Jul 2009 13:08:13 +0200 Subject: [PATCH] Bug #588398 - Leak with testgtk::preview_(color|gray) and more Revert to gdk_win32_ref_cairo_surface() implementation from gtk-2-16 and make _gdk_windowing_create_cairo_surface() simply delegate to it. --- gdk/win32/gdkdrawable-win32.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gdk/win32/gdkdrawable-win32.c b/gdk/win32/gdkdrawable-win32.c index d5a4376b85..8975c9cb78 100644 --- a/gdk/win32/gdkdrawable-win32.c +++ b/gdk/win32/gdkdrawable-win32.c @@ -1883,10 +1883,8 @@ _gdk_windowing_create_cairo_surface (GdkDrawable *drawable, gint width, gint height) { - HDC hdc = _gdk_win32_drawable_acquire_dc (drawable); - if (!hdc) - return NULL; - return cairo_win32_surface_create (hdc); + /* width and height are determined from the DC */ + return gdk_win32_ref_cairo_surface (drawable); } static void @@ -1909,16 +1907,17 @@ gdk_win32_ref_cairo_surface (GdkDrawable *drawable) if (!impl->cairo_surface) { - // On Win32 cairo surface, width and height are determined from the DC - impl->cairo_surface = _gdk_windowing_create_cairo_surface (drawable, 0, 0); + HDC hdc = _gdk_win32_drawable_acquire_dc (drawable); + if (!hdc) + return NULL; + + impl->cairo_surface = cairo_win32_surface_create (hdc); cairo_surface_set_user_data (impl->cairo_surface, &gdk_win32_cairo_key, drawable, gdk_win32_cairo_surface_destroy); } else - { - cairo_surface_reference (impl->cairo_surface); - } + cairo_surface_reference (impl->cairo_surface); return impl->cairo_surface; } @@ -1977,6 +1976,6 @@ _gdk_win32_drawable_finish (GdkDrawable *drawable) cairo_surface_set_user_data (impl->cairo_surface, &gdk_win32_cairo_key, NULL, NULL); } - //TODO_CSW: g_assert (impl->hdc_count == 0); + g_assert (impl->hdc_count == 0); }