[Win32k]
authorJames Tabor <james.tabor@reactos.org>
Sat, 21 Apr 2012 18:18:59 +0000 (18:18 +0000)
committerJames Tabor <james.tabor@reactos.org>
Sat, 21 Apr 2012 18:18:59 +0000 (18:18 +0000)
- Troubleshooting bug 5630, moved DestroyProcessClasses from process to thread since process is called first. This way, it is assured the class destruction is on queue, but not before thread death.
- Added a global pointer to be used in a later commit.
- Warning: this does not fix bug 5630.

svn path=/trunk/; revision=56386

reactos/win32ss/user/ntuser/class.c
reactos/win32ss/user/ntuser/main.c
reactos/win32ss/user/ntuser/ntuser.c
reactos/win32ss/user/ntuser/ntuser.h

index 1474e0c..f54626d 100644 (file)
@@ -128,6 +128,7 @@ static VOID
 IntDestroyClass(IN OUT PCLS Class)
 {
     PDESKTOP pDesk;
+
     /* There shouldn't be any clones anymore */
     ASSERT(Class->cWndReferenceCount == 0);
     ASSERT(Class->pclsClone == NULL);
@@ -620,9 +621,11 @@ IntDereferenceClass(IN OUT PCLS Class,
 {
     PCLS *PrevLink, BaseClass, CurrentClass;
 
+    ASSERT(Class->cWndReferenceCount >= 1);
+
     BaseClass = Class->pclsBase;
 
-    if (--Class->cWndReferenceCount <= 0)
+    if (--Class->cWndReferenceCount == 0)
     {
         if (BaseClass == Class)
         {
index 9c145b2..8543fa4 100644 (file)
@@ -175,9 +175,6 @@ Win32kProcessCallback(struct _EPROCESS *Process,
         IntCleanupMenus(Process, ppiCurrent);
         IntCleanupCurIcons(Process, ppiCurrent);
 
-        /* no process windows should exist at this point, or the function will assert! */
-        DestroyProcessClasses(ppiCurrent);
-        ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
 
         GDI_CleanupForProcess(Process);
 
@@ -205,6 +202,8 @@ Win32kProcessCallback(struct _EPROCESS *Process,
         GdiPoolDestroy(ppiCurrent->pPoolBrushAttr);
         GdiPoolDestroy(ppiCurrent->pPoolRgnAttr);
 
+        if (gppiInputProvider == ppiCurrent) gppiInputProvider = NULL;
+
         TRACE_CH(UserProcess,"Freeing ppi 0x%x\n", ppiCurrent);
 
         /* Ftee the PROCESSINFO */
@@ -432,7 +431,22 @@ UserDestroyThreadInfo(struct _ETHREAD *Thread)
         DestroyTimersForThread(ptiCurrent);
         KeSetEvent(ptiCurrent->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
         UnregisterThreadHotKeys(Thread);
+/*
+        if (IsListEmpty(&ptiCurrent->WindowListHead))
+        {
+           ERR_CH(UserThread,"Thread Window List is Empty!\n");
+        }
+*/
         co_DestroyThreadWindows(Thread);
+
+        if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling)
+        {
+           //ERR_CH(UserThread,"DestroyProcessClasses\n");
+          /* no process windows should exist at this point, or the function will assert! */
+           DestroyProcessClasses(ppiCurrent);
+           ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
+        }
+
         IntBlockInput(ptiCurrent, FALSE);
         IntCleanupThreadCallbacks(ptiCurrent);
 
index e5478c4..e7b505e 100644 (file)
@@ -11,6 +11,7 @@ DBG_DEFAULT_CHANNEL(UserMisc);
 /* GLOBALS *******************************************************************/
 
 PTHREADINFO gptiCurrent = NULL;
+PPROCESSINFO gppiInputProvider = NULL;
 ERESOURCE UserLock;
 ATOM AtomMessage; // Window Message atom.
 ATOM AtomWndObj;  // Window Object atom.
index 1f97e95..b45a2d0 100644 (file)
@@ -13,6 +13,7 @@ extern BOOL gbInitialized;
 extern PSERVERINFO gpsi;
 extern PTHREADINFO gptiCurrent;
 extern PPROCESSINFO ppiScrnSaver;
+extern PPROCESSINFO gppiInputProvider;
 
 INIT_FUNCTION NTSTATUS NTAPI InitUserImpl(VOID);
 VOID FASTCALL CleanupUserImpl(VOID);