Commit 0c9bc0ed authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Delay writing metafile file until CloseMetaFile is called.

parent d19ac108
......@@ -325,7 +325,6 @@ HDC WINAPI CreateMetaFileW( LPCWSTR filename )
DC *dc;
METAFILEDRV_PDEVICE *physDev;
HANDLE hFile;
DWORD bytes_written;
TRACE("%s\n", debugstr_w(filename) );
......@@ -340,12 +339,6 @@ HDC WINAPI CreateMetaFileW( LPCWSTR filename )
free_dc_ptr( dc );
return 0;
}
if (!WriteFile( hFile, physDev->mh, sizeof(*physDev->mh),
&bytes_written, NULL )) {
free_dc_ptr( dc );
CloseHandle (hFile );
return 0;
}
physDev->hFile = hFile;
/* Grow METAHEADER to include filename */
......@@ -422,19 +415,13 @@ static DC *MFDRV_CloseMetaFile( HDC hdc )
if (physDev->mh->mtType == METAFILE_DISK) /* disk based metafile */
{
if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0) {
free_dc_ptr( dc );
return 0;
}
physDev->mh->mtType = METAFILE_MEMORY; /* This is what windows does */
if (!WriteFile(physDev->hFile, physDev->mh, sizeof(*physDev->mh),
if (!WriteFile(physDev->hFile, physDev->mh, physDev->mh->mtSize * 2,
&bytes_written, NULL)) {
free_dc_ptr( dc );
return 0;
}
CloseHandle(physDev->hFile);
physDev->mh->mtType = METAFILE_DISK;
}
return dc;
......@@ -481,9 +468,6 @@ BOOL MFDRV_WriteRecord( PHYSDEV dev, METARECORD *mr, DWORD rlen)
METAHEADER *mh;
METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dev;
switch(physDev->mh->mtType)
{
case METAFILE_MEMORY:
len = physDev->mh->mtSize * 2 + rlen;
/* reallocate memory if needed */
size = HeapSize( GetProcessHeap(), 0, physDev->mh );
......@@ -497,16 +481,6 @@ BOOL MFDRV_WriteRecord( PHYSDEV dev, METARECORD *mr, DWORD rlen)
TRACE("Reallocated metafile: new size is %d\n",size);
}
memcpy((WORD *)physDev->mh + physDev->mh->mtSize, mr, rlen);
break;
case METAFILE_DISK:
TRACE("Writing record to disk\n");
if (!WriteFile(physDev->hFile, mr, rlen, NULL, NULL))
return FALSE;
break;
default:
ERR("Unknown metafile type %d\n", physDev->mh->mtType );
return FALSE;
}
physDev->mh->mtSize += rlen / 2;
physDev->mh->mtMaxRecord = max(physDev->mh->mtMaxRecord, rlen / 2);
......
......@@ -3043,7 +3043,6 @@ static void test_metafile_file(void)
ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
size = GetFileSize(file, NULL);
todo_wine
ok(!size, "size = %u\n", size);
ret = MoveToEx(dc, 1, 1, NULL);
......@@ -3056,7 +3055,6 @@ static void test_metafile_file(void)
ok( ret, "Ellipse error %d.\n", GetLastError());
size = GetFileSize(file, NULL);
todo_wine
ok(!size, "size = %u\n", size);
metafile = CloseMetaFile(dc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment