Delete all GLDCDATA structures in wglDeleteContext that share the same ICD

svn path=/trunk/; revision=30450
This commit is contained in:
Thomas Bluemel 2007-11-15 00:13:57 +00:00
parent 349ba2667d
commit 0e033bbd53
2 changed files with 48 additions and 6 deletions

View file

@ -521,11 +521,8 @@ OPENGL32_UnloadICD( GLDRIVERDATA *icd )
return FALSE; /* FIXME: do we have to expect such an error and handle it? */
}
icd->refcount--;
if (icd->refcount == 0)
// if (0)
if (--icd->refcount == 0)
ret = OPENGL32_UnloadDriver( icd );
/* FIXME: InitializeICD crashes when called a second time */
/* release mutex */
if (!ReleaseMutex( OPENGL32_processdata.driver_mutex ))

View file

@ -122,7 +122,7 @@ ROSGL_RemoveContext( GLRC *glrc )
*/
static
GLRC *
ROSGL_NewContext()
ROSGL_NewContext(void)
{
GLRC *glrc;
@ -136,6 +136,51 @@ ROSGL_NewContext()
return glrc;
}
/*! \brief Delete all GLDCDATA with this IDC
*
* \param icd [IN] Pointer to a ICD
*/
static
VOID
ROSGL_DeleteDCDataForICD( GLDRIVERDATA *icd )
{
GLDCDATA *p, **pptr;
/* synchronize */
if (WaitForSingleObject( OPENGL32_processdata.dcdata_mutex, INFINITE ) ==
WAIT_FAILED)
{
DBGPRINT( "Error: WaitForSingleObject() failed (%d)", GetLastError() );
return;
}
p = OPENGL32_processdata.dcdata_list;
pptr = &OPENGL32_processdata.dcdata_list;
while (p != NULL)
{
if (p->icd == icd)
{
*pptr = p->next;
OPENGL32_UnloadICD( p->icd );
if (!HeapFree( GetProcessHeap(), 0, p ))
DBGPRINT( "Warning: HeapFree() on GLDCDATA failed (%d)",
GetLastError() );
p = *pptr;
}
else
{
pptr = &p->next;
p = p->next;
}
}
/* release mutex */
if (!ReleaseMutex( OPENGL32_processdata.dcdata_mutex ))
DBGPRINT( "Error: ReleaseMutex() failed (%d)", GetLastError() );
}
/*! \brief Delete a GL Context (GLRC) and remove it from the list
*
@ -150,7 +195,7 @@ ROSGL_DeleteContext( GLRC *glrc )
{
/* unload icd */
if (glrc->icd != NULL)
OPENGL32_UnloadICD( glrc->icd );
ROSGL_DeleteDCDataForICD( glrc->icd );
/* remove from list */
ROSGL_RemoveContext( glrc );