Nikolay Sivov : gdi32: Use supplied hdc for DIB_RGB_COLORS if it's valid.

Alexandre Julliard julliard at winehq.org
Mon Apr 12 09:54:07 CDT 2010


Module: wine
Branch: master
Commit: 352e2ff6eb5116d2ac91db9258ae288733e3a271
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=352e2ff6eb5116d2ac91db9258ae288733e3a271

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Apr 12 13:00:45 2010 +0400

gdi32: Use supplied hdc for DIB_RGB_COLORS if it's valid.

This is about fixing regression introduced with 2854884a428e222cbb9078d875068a72f25365c4.
Initial patch fixed MSVS 2005 toolbars blackness, this one doesn't break a fix,
and fixes regressed Animation control glitches (and probably reported games related problems).

---

 dlls/gdi32/dib.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 767c0a9..eebc321 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -332,21 +332,26 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
 		      UINT lines, LPCVOID bits, const BITMAPINFO *info,
 		      UINT coloruse )
 {
-    DC *dc;
+    DC *dc = get_dc_ptr( hdc );
+    BOOL delete_hdc = FALSE;
     BITMAPOBJ *bitmap;
     INT result = 0;
 
-    if (coloruse == DIB_RGB_COLORS) hdc = CreateCompatibleDC(0);
+    if (coloruse == DIB_RGB_COLORS && !dc)
+    {
+        hdc = CreateCompatibleDC(0);
+        dc = get_dc_ptr( hdc );
+        delete_hdc = TRUE;
+    }
 
-    if (!(dc = get_dc_ptr( hdc )))
-        return 0;
+    if (!dc) return 0;
 
     update_dc( dc );
 
     if (!(bitmap = GDI_GetObjPtr( hbitmap, OBJ_BITMAP )))
     {
         release_dc_ptr( dc );
-        if (coloruse == DIB_RGB_COLORS) DeleteDC(hdc);
+        if (delete_hdc) DeleteDC(hdc);
         return 0;
     }
 
@@ -365,7 +370,7 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
  done:
     GDI_ReleaseObj( hbitmap );
     release_dc_ptr( dc );
-    if (coloruse == DIB_RGB_COLORS) DeleteDC(hdc);
+    if (delete_hdc) DeleteDC(hdc);
     return result;
 }
 




More information about the wine-cvs mailing list