[ros-diffs] [weiden] 30450: Delete all GLDCDATA structures in wglDeleteContext that share the same ICD

weiden at svn.reactos.org weiden at svn.reactos.org
Thu Nov 15 01:13:58 CET 2007


Author: weiden
Date: Thu Nov 15 03:13:57 2007
New Revision: 30450

URL: http://svn.reactos.org/svn/reactos?rev=30450&view=rev
Log:
Delete all GLDCDATA structures in wglDeleteContext that share the same ICD

Modified:
    trunk/reactos/dll/win32/opengl32/opengl32.c
    trunk/reactos/dll/win32/opengl32/wgl.c

Modified: trunk/reactos/dll/win32/opengl32/opengl32.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/opengl32/opengl32.c?rev=30450&r1=30449&r2=30450&view=diff
==============================================================================
--- trunk/reactos/dll/win32/opengl32/opengl32.c (original)
+++ trunk/reactos/dll/win32/opengl32/opengl32.c Thu Nov 15 03:13:57 2007
@@ -521,11 +521,8 @@
 		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 ))

Modified: trunk/reactos/dll/win32/opengl32/wgl.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/opengl32/wgl.c?rev=30450&r1=30449&r2=30450&view=diff
==============================================================================
--- trunk/reactos/dll/win32/opengl32/wgl.c (original)
+++ trunk/reactos/dll/win32/opengl32/wgl.c Thu Nov 15 03:13:57 2007
@@ -122,7 +122,7 @@
  */
 static
 GLRC *
-ROSGL_NewContext()
+ROSGL_NewContext(void)
 {
 	GLRC *glrc;
 
@@ -136,6 +136,51 @@
 	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 @@
 {
 	/* unload icd */
 	if (glrc->icd != NULL)
-		OPENGL32_UnloadICD( glrc->icd );
+		ROSGL_DeleteDCDataForICD( glrc->icd );
 
 	/* remove from list */
 	ROSGL_RemoveContext( glrc );




More information about the Ros-diffs mailing list