Try to fix orange: sGlobalObserver can get set during event processing, not
just unset.
Bug 326777
--- 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