Try to fix orange: sGlobalObserver can get set during event processing, not
authorbzbarsky@mit.edu
Tue, 10 Jul 2007 20:01:56 -0700
changeset 3312 773cbb1213f376480e676521e9850bb55cfa6b43
parent 3311 b5f66d17a428af88183ea285b138e6533f7060db
child 3313 a67df69e95bbd15a414791f8d2820fa3f45f4c52
push idunknown
push userunknown
push dateunknown
bugs326777
milestone1.9a7pre
Try to fix orange: sGlobalObserver can get set during event processing, not just unset. Bug 326777
xpcom/threads/nsThread.cpp
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -462,17 +462,18 @@ nsThread::HasPendingEvents(PRBool *resul
 
 NS_IMETHODIMP
 nsThread::ProcessNextEvent(PRBool mayWait, PRBool *result)
 {
   LOG(("THRD(%p) ProcessNextEvent [%u %u]\n", this, mayWait, mRunningEvent));
 
   NS_ENSURE_STATE(PR_GetCurrentThread() == mThread);
 
-  if (sGlobalObserver) 
+  PRBool notifyGlobalObserver = (sGlobalObserver != nsnull);
+  if (notifyGlobalObserver) 
     sGlobalObserver->OnProcessNextEvent(this, mayWait && !ShuttingDown(),
                                         mRunningEvent);
 
   nsCOMPtr<nsIThreadObserver> obs = mObserver;
   if (obs)
     obs->OnProcessNextEvent(this, mayWait && !ShuttingDown(), mRunningEvent);
 
   // If we are shutting down, then do not wait for new events.
@@ -491,17 +492,17 @@ nsThread::ProcessNextEvent(PRBool mayWai
   } else if (mayWait) {
     NS_ASSERTION(ShuttingDown(), "This should only happen when shutting down");
     rv = NS_ERROR_UNEXPECTED;
   }
 
   if (obs)
     obs->AfterProcessNextEvent(this, mRunningEvent);
 
-  if (sGlobalObserver)
+  if (notifyGlobalObserver && sGlobalObserver)
     sGlobalObserver->AfterProcessNextEvent(this, mRunningEvent);
 
   return rv;
 }
 
 //-----------------------------------------------------------------------------
 // nsISupportsPriority