Commit ffb5f749 authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

ddraw: Handle refcount of lights when interacting with viewport.

parent 8681d490
......@@ -751,6 +751,7 @@ IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
/* Add the light in the 'linked' chain */
lpDirect3DLightImpl->next = This->lights;
This->lights = lpDirect3DLightImpl;
IDirect3DLight_AddRef(lpDirect3DLight);
/* Attach the light to the viewport */
lpDirect3DLightImpl->active_viewport = This;
......@@ -796,6 +797,7 @@ IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *iface,
else prev_light->next = cur_light->next;
/* Detach the light to the viewport */
cur_light->active_viewport = NULL;
IDirect3DLight_Release( (IDirect3DLight *)cur_light );
This->num_lights--;
This->map_lights &= ~(1<<lpDirect3DLightImpl->dwLightIndex);
LeaveCriticalSection(&ddraw_cs);
......@@ -871,6 +873,9 @@ IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface,
break;
}
if (*lplpDirect3DLight)
IDirect3DLight_AddRef(*lplpDirect3DLight);
LeaveCriticalSection(&ddraw_cs);
return *lplpDirect3DLight ? D3D_OK : DDERR_INVALIDPARAMS;
......
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