[gtk+/gtk-2-24] win32: ensure proper error is reported when CreateDIBSection() fails



commit 0df60513cb97a2f33566e0c69308ff3dc20a7fa6
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Mon Apr 22 14:50:33 2013 +0200

    win32: ensure proper error is reported when CreateDIBSection() fails
    
    GetLastError() should be called immediately after the failure, so call
    WIN32_GDI_FAILED() just after the CreateDIBSection() error, not after
    ReleaseDC().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=698563

 gdk/win32/gdkpixmap-win32.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gdk/win32/gdkpixmap-win32.c b/gdk/win32/gdkpixmap-win32.c
index 6d18ca4..883efbe 100644
--- a/gdk/win32/gdkpixmap-win32.c
+++ b/gdk/win32/gdkpixmap-win32.c
@@ -293,15 +293,15 @@ _gdk_pixmap_new (GdkDrawable *drawable,
       bmi.u.bmiMasks[1] = visual->green_mask;
       bmi.u.bmiMasks[2] = visual->blue_mask;
 
-      hbitmap = CreateDIBSection (hdc, (BITMAPINFO *) &bmi,
-                                 iUsage, (PVOID *) &bits, NULL, 0);
-      GDI_CALL (ReleaseDC, (hwnd, hdc));
-      if (hbitmap == NULL)
+      if ((hbitmap = CreateDIBSection (hdc, (BITMAPINFO *) &bmi,
+                                      iUsage, (PVOID *) &bits, NULL, 0)) == NULL)
        {
          WIN32_GDI_FAILED ("CreateDIBSection");
+         GDI_CALL (ReleaseDC, (hwnd, hdc));
          g_object_unref ((GObject *) pixmap);
          return NULL;
        }
+      GDI_CALL (ReleaseDC, (hwnd, hdc));
 
       dib_surface = cairo_image_surface_create_for_data (bits,
                                                         format, width, height,


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