NtGdiRestoreDC

1. fix do not delete all hdc and the restore hdc. 
2. fix calc of SaveLevel the calc are not perfect

we only have 6 fails when we try restore dc now with wine gdi32 test dc 

svn path=/trunk/; revision=24268
This commit is contained in:
Magnus Olsen 2006-09-25 18:50:40 +00:00
parent b79a852fe5
commit 888f16ea6f

View file

@ -1940,55 +1940,57 @@ NtGdiRestoreDC(HDC hDC, INT SaveLevel)
return FALSE; return FALSE;
} }
if (SaveLevel == -1) if(abs(SaveLevel) > dc->saveLevel || SaveLevel == 0)
SaveLevel = dc->saveLevel;
if ((SaveLevel < 1) || (SaveLevel > dc->saveLevel))
{ {
DC_UnlockDc(dc); DC_UnlockDc(dc);
return FALSE; return FALSE;
} }
success = TRUE; /* FIXME this calc are not 100% correct I think ??*/
if (SaveLevel < 0) SaveLevel = dc->saveLevel + SaveLevel + 1;
success=TRUE;
while (dc->saveLevel >= SaveLevel) while (dc->saveLevel >= SaveLevel)
{ {
HDC hdcs = DC_GetNextDC (dc); HDC hdcs = DC_GetNextDC (dc);
dcs = DC_LockDc (hdcs); dcs = DC_LockDc (hdcs);
if (dcs == NULL) if (dcs == NULL)
{ {
DC_UnlockDc(dc); DC_UnlockDc(dc);
return FALSE; return FALSE;
} }
DC_SetNextDC (dcs, DC_GetNextDC (dcs));
if (--dc->saveLevel < SaveLevel) DC_SetNextDC (dc, DC_GetNextDC (dcs));
{ dcs->hNext = 0;
DC_UnlockDc( dc );
DC_UnlockDc( dcs ); if (--dc->saveLevel < SaveLevel)
NtGdiSetDCState(hDC, hdcs); {
#if 0 DC_UnlockDc( dc );
if (!PATH_AssignGdiPath( &dc->w.path, &dcs->w.path )) DC_UnlockDc( dcs );
{
/* FIXME: This might not be quite right, since we're NtGdiSetDCState(hDC, hdcs);
* returning FALSE but still destroying the saved DC state */ //if (!PATH_AssignGdiPath( &dc->path, &dcs->path ))
success = FALSE; /* FIXME: This might not be quite right, since we're
} * returning FALSE but still destroying the saved DC state
#endif */
dc = DC_LockDc(hDC); success=FALSE;
if(!dc) dc = DC_LockDc(hDC);
{ if(!dc)
return FALSE; {
} return FALSE;
} }
else }
{ else
DC_UnlockDc( dcs ); {
} DC_UnlockDc( dcs );
NtGdiDeleteObjectApp (hdcs); }
NtGdiDeleteObjectApp (hdcs);
} }
DC_UnlockDc( dc ); DC_UnlockDc( dc );
return success; return success;
} }
INT STDCALL INT STDCALL
NtGdiSaveDC(HDC hDC) NtGdiSaveDC(HDC hDC)