From f9ebe5ab8fdf0485c269d78dd6897f714c579e3e Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 12 Sep 2007 20:23:03 +0200 Subject: [PATCH] gdi32: Don't store a DC pointer in the metafile devices. --- dlls/gdi32/enhmfdrv/dc.c | 4 +++- dlls/gdi32/enhmfdrv/enhmetafiledrv.h | 1 - dlls/gdi32/enhmfdrv/init.c | 16 +++++++--------- dlls/gdi32/mfdrv/init.c | 20 +++++++++----------- dlls/gdi32/mfdrv/metafiledrv.h | 1 - 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/dlls/gdi32/enhmfdrv/dc.c b/dlls/gdi32/enhmfdrv/dc.c index 74300b43a91..01159916023 100644 --- a/dlls/gdi32/enhmfdrv/dc.c +++ b/dlls/gdi32/enhmfdrv/dc.c @@ -34,6 +34,7 @@ INT EMFDRV_SaveDC( PHYSDEV dev ) BOOL EMFDRV_RestoreDC( PHYSDEV dev, INT level ) { EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev; + DC *dc = get_dc_ptr( physDev->hdc ); EMRRESTOREDC emr; emr.emr.iType = EMR_RESTOREDC; @@ -42,10 +43,11 @@ BOOL EMFDRV_RestoreDC( PHYSDEV dev, INT level ) if (level < 0) emr.iRelative = level; else - emr.iRelative = level - physDev->dc->saveLevel - 1; + emr.iRelative = level - dc->saveLevel - 1; EMFDRV_WriteRecord( dev, &emr.emr ); + release_dc_ptr( dc ); return TRUE; } diff --git a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h index b0d6bf09d70..b3e60645d73 100644 --- a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h +++ b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h @@ -33,7 +33,6 @@ typedef struct { HDC hdc; - DC *dc; ENHMETAHEADER *emh; /* Pointer to enhanced metafile header */ UINT handles_size, cur_handles; HGDIOBJ *handles; diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c index d272f7520d1..f5c4562060d 100644 --- a/dlls/gdi32/enhmfdrv/init.c +++ b/dlls/gdi32/enhmfdrv/init.c @@ -159,10 +159,9 @@ static const DC_FUNCTIONS EMFDRV_Funcs = /********************************************************************** * EMFDRV_DeleteDC */ -static BOOL EMFDRV_DeleteDC( PHYSDEV dev ) +static BOOL EMFDRV_DeleteDC( DC *dc ) { - EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev; - DC *dc = physDev->dc; + EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dc->physDev; UINT index; if (physDev->emh) HeapFree( GetProcessHeap(), 0, physDev->emh ); @@ -324,7 +323,6 @@ HDC WINAPI CreateEnhMetaFileW( } dc->physDev = (PHYSDEV)physDev; physDev->hdc = dc->hSelf; - physDev->dc = dc; if(description) { /* App name\0Title\0\0 */ length = lstrlenW(description); @@ -405,11 +403,11 @@ HDC WINAPI CreateEnhMetaFileW( { if ((hFile = CreateFileW(filename, GENERIC_WRITE | GENERIC_READ, 0, NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) { - EMFDRV_DeleteDC( dc->physDev ); + EMFDRV_DeleteDC( dc ); return 0; } if (!WriteFile( hFile, (LPSTR)physDev->emh, size, NULL, NULL )) { - EMFDRV_DeleteDC( dc->physDev ); + EMFDRV_DeleteDC( dc ); return 0; } physDev->hFile = hFile; @@ -479,7 +477,7 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */ if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0) { CloseHandle( physDev->hFile ); - EMFDRV_DeleteDC( dc->physDev ); + EMFDRV_DeleteDC( dc ); return 0; } @@ -487,7 +485,7 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */ sizeof(*physDev->emh), NULL, NULL)) { CloseHandle( physDev->hFile ); - EMFDRV_DeleteDC( dc->physDev ); + EMFDRV_DeleteDC( dc ); return 0; } HeapFree( GetProcessHeap(), 0, physDev->emh ); @@ -502,6 +500,6 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */ hmf = EMF_Create_HENHMETAFILE( physDev->emh, (physDev->hFile != 0) ); physDev->emh = NULL; /* So it won't be deleted */ - EMFDRV_DeleteDC( dc->physDev ); + EMFDRV_DeleteDC( dc ); return hmf; } diff --git a/dlls/gdi32/mfdrv/init.c b/dlls/gdi32/mfdrv/init.c index a73c7013262..aa10e96caf2 100644 --- a/dlls/gdi32/mfdrv/init.c +++ b/dlls/gdi32/mfdrv/init.c @@ -175,7 +175,6 @@ static DC *MFDRV_AllocMetaFile(void) } dc->physDev = (PHYSDEV)physDev; physDev->hdc = dc->hSelf; - physDev->dc = dc; if (!(physDev->mh = HeapAlloc( GetProcessHeap(), 0, sizeof(*physDev->mh) ))) { @@ -204,10 +203,9 @@ static DC *MFDRV_AllocMetaFile(void) /********************************************************************** * MFDRV_DeleteDC */ -static BOOL MFDRV_DeleteDC( PHYSDEV dev ) +static BOOL MFDRV_DeleteDC( DC *dc ) { - METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dev; - DC *dc = physDev->dc; + METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dc->physDev; DWORD index; HeapFree( GetProcessHeap(), 0, physDev->mh ); @@ -251,12 +249,12 @@ HDC WINAPI CreateMetaFileW( LPCWSTR filename ) physDev->mh->mtType = METAFILE_DISK; if ((hFile = CreateFileW(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) { - MFDRV_DeleteDC( dc->physDev ); + MFDRV_DeleteDC( dc ); return 0; } if (!WriteFile( hFile, physDev->mh, sizeof(*physDev->mh), NULL, NULL )) { - MFDRV_DeleteDC( dc->physDev ); + MFDRV_DeleteDC( dc ); return 0; } physDev->hFile = hFile; @@ -328,21 +326,21 @@ static DC *MFDRV_CloseMetaFile( HDC hdc ) if (!MFDRV_MetaParam0(dc->physDev, META_EOF)) { - MFDRV_DeleteDC( dc->physDev ); + MFDRV_DeleteDC( dc ); return 0; } if (physDev->mh->mtType == METAFILE_DISK) /* disk based metafile */ { if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0) { - MFDRV_DeleteDC( dc->physDev ); + MFDRV_DeleteDC( dc ); return 0; } physDev->mh->mtType = METAFILE_MEMORY; /* This is what windows does */ if (!WriteFile(physDev->hFile, (LPSTR)physDev->mh, sizeof(*physDev->mh), NULL, NULL)) { - MFDRV_DeleteDC( dc->physDev ); + MFDRV_DeleteDC( dc ); return 0; } CloseHandle(physDev->hFile); @@ -394,7 +392,7 @@ HMETAFILE16 WINAPI CloseMetaFile16(HDC16 hdc) hmf = MF_Create_HMETAFILE16( physDev->mh ); physDev->mh = NULL; /* So it won't be deleted */ - MFDRV_DeleteDC( dc->physDev ); + MFDRV_DeleteDC( dc ); return hmf; } @@ -423,7 +421,7 @@ HMETAFILE WINAPI CloseMetaFile(HDC hdc) hmf = MF_Create_HMETAFILE( physDev->mh ); physDev->mh = NULL; /* So it won't be deleted */ - MFDRV_DeleteDC( dc->physDev ); + MFDRV_DeleteDC( dc ); return hmf; } diff --git a/dlls/gdi32/mfdrv/metafiledrv.h b/dlls/gdi32/mfdrv/metafiledrv.h index 00cb8d49d9c..df9032f6add 100644 --- a/dlls/gdi32/mfdrv/metafiledrv.h +++ b/dlls/gdi32/mfdrv/metafiledrv.h @@ -33,7 +33,6 @@ typedef struct { HDC hdc; - DC *dc; METAHEADER *mh; /* Pointer to metafile header */ UINT handles_size, cur_handles; HGDIOBJ *handles;