Module: wine Branch: master Commit: 5e507b3e3dc999ae55f314f863ea613a14f0ae84 URL: https://gitlab.winehq.org/wine/wine/-/commit/5e507b3e3dc999ae55f314f863ea613...
Author: Piotr Caban piotr@codeweavers.com Date: Wed Oct 11 00:39:01 2023 +0200
gdi32: Fix METADC handling in PlayMetaFile.
---
dlls/gdi32/metafile.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/dlls/gdi32/metafile.c b/dlls/gdi32/metafile.c index 50910956e1d..911dfeecf61 100644 --- a/dlls/gdi32/metafile.c +++ b/dlls/gdi32/metafile.c @@ -360,6 +360,7 @@ HMETAFILE WINAPI CopyMetaFileA( HMETAFILE hSrcMetaFile, LPCSTR lpFilename ) */ BOOL WINAPI PlayMetaFile( HDC hdc, HMETAFILE hmf ) { + BOOL metadc = GetObjectType(hdc) == OBJ_METADC; METAHEADER *mh = get_metafile_bits( hmf ); METARECORD *mr; HANDLETABLE *ht; @@ -372,16 +373,19 @@ BOOL WINAPI PlayMetaFile( HDC hdc, HMETAFILE hmf )
if (!mh) return FALSE;
- /* save DC */ - hPen = GetCurrentObject(hdc, OBJ_PEN); - hBrush = GetCurrentObject(hdc, OBJ_BRUSH); - hPal = GetCurrentObject(hdc, OBJ_PAL); - - hRgn = NtGdiCreateRectRgn(0, 0, 0, 0); - if (!GetClipRgn(hdc, hRgn)) + if (!metadc) { - DeleteObject(hRgn); - hRgn = 0; + /* save DC */ + hPen = GetCurrentObject(hdc, OBJ_PEN); + hBrush = GetCurrentObject(hdc, OBJ_BRUSH); + hPal = GetCurrentObject(hdc, OBJ_PAL); + + hRgn = NtGdiCreateRectRgn(0, 0, 0, 0); + if (!GetClipRgn(hdc, hRgn)) + { + DeleteObject(hRgn); + hRgn = 0; + } }
/* create the handle table */ @@ -414,12 +418,15 @@ BOOL WINAPI PlayMetaFile( HDC hdc, HMETAFILE hmf ) PlayMetaFileRecord( hdc, ht, mr, mh->mtNoObjects ); }
- /* restore DC */ - SelectObject(hdc, hPen); - SelectObject(hdc, hBrush); - SelectPalette(hdc, hPal, FALSE); - ExtSelectClipRgn(hdc, hRgn, RGN_COPY); - DeleteObject(hRgn); + if (!metadc) + { + /* restore DC */ + SelectObject(hdc, hPen); + SelectObject(hdc, hBrush); + SelectPalette(hdc, hPal, FALSE); + ExtSelectClipRgn(hdc, hRgn, RGN_COPY); + DeleteObject(hRgn); + }
/* free objects in handle table */ for(i = 0; i < mh->mtNoObjects; i++)