mirror of
https://github.com/reactos/wine.git
synced 2025-01-21 03:15:18 +00:00
Fix palette deletion issue seen in DungeonKeeper.
This commit is contained in:
parent
2ae876fadf
commit
2b8281a827
@ -1307,6 +1307,8 @@ void Main_DirectDraw_AddPalette(IDirectDrawImpl* This,
|
||||
void Main_DirectDraw_RemovePalette(IDirectDrawImpl* This,
|
||||
IDirectDrawPaletteImpl* palette)
|
||||
{
|
||||
IDirectDrawSurfaceImpl *surf;
|
||||
|
||||
assert(palette->ddraw_owner == This);
|
||||
|
||||
if (This->palettes == palette)
|
||||
@ -1316,6 +1318,17 @@ void Main_DirectDraw_RemovePalette(IDirectDrawImpl* This,
|
||||
palette->next_ddraw->prev_ddraw = palette->prev_ddraw;
|
||||
if (palette->prev_ddraw)
|
||||
palette->prev_ddraw->next_ddraw = palette->next_ddraw;
|
||||
|
||||
/* Here we need also to remove tha palette from any surface which has it as the
|
||||
* current palette (checked on Windows)
|
||||
*/
|
||||
for (surf = This->surfaces; surf != NULL; surf = surf->next_ddraw) {
|
||||
if (surf->palette == palette) {
|
||||
TRACE("Palette %p attached to surface %p.\n", palette, surf);
|
||||
surf->palette = NULL;
|
||||
surf->set_palette(surf, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Main_DirectDraw_DeletePalettes(IDirectDrawImpl* This)
|
||||
|
@ -1211,6 +1211,7 @@ Main_DirectDrawSurface_SetPalette(LPDIRECTDRAWSURFACE7 iface,
|
||||
LPDIRECTDRAWPALETTE pPalette)
|
||||
{
|
||||
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
||||
IDirectDrawPalette *pal_to_rel = NULL;
|
||||
|
||||
TRACE("(%p)->(%p)\n",This,pPalette);
|
||||
if (pPalette == ICOM_INTERFACE(This->palette, IDirectDrawPalette))
|
||||
@ -1219,8 +1220,7 @@ Main_DirectDrawSurface_SetPalette(LPDIRECTDRAWSURFACE7 iface,
|
||||
if (This->palette != NULL) {
|
||||
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
||||
This->palette->global.dwFlags &= ~DDPCAPS_PRIMARYSURFACE;
|
||||
IDirectDrawPalette_Release(ICOM_INTERFACE(This->palette,
|
||||
IDirectDrawPalette));
|
||||
pal_to_rel = ICOM_INTERFACE(This->palette, IDirectDrawPalette);
|
||||
}
|
||||
|
||||
This->palette = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette,
|
||||
@ -1233,6 +1233,12 @@ Main_DirectDrawSurface_SetPalette(LPDIRECTDRAWSURFACE7 iface,
|
||||
|
||||
This->set_palette(This, This->palette);
|
||||
|
||||
/* Do the palette release at the end to prevent doing some 'loop' when removing
|
||||
* the surface maintaining the last reference on a palette.
|
||||
*/
|
||||
if (pal_to_rel != NULL)
|
||||
IDirectDrawPalette_Release(pal_to_rel);
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user