Bug 717498 - Clear nsThread::mEventObservers at thread shutdown. r=bsmedberg

This commit is contained in:
Bobby Holley 2012-01-14 10:31:13 -08:00
parent b4cfcc0491
commit 3695ee3b7a
3 changed files with 9 additions and 0 deletions

View File

@ -506,6 +506,11 @@ nsThread::Shutdown()
PR_JoinThread(mThread);
mThread = nsnull;
// We hold strong references to our event observers, and once the thread is
// shut down the observers can't easily unregister themselves. Do it here
// to avoid leaking.
ClearObservers();
#ifdef DEBUG
{
MutexAutoLock lock(mLock);

View File

@ -77,6 +77,9 @@ public:
// nsIThreadManager::NewThread.
bool ShutdownRequired() { return mShutdownRequired; }
// Clear the observer list.
void ClearObservers() { mEventObservers.Clear(); }
// The global thread observer
static nsIThreadObserver* sGlobalObserver;

View File

@ -176,6 +176,7 @@ nsThreadManager::Shutdown()
// main thread is special we do it manually here after we're sure all events
// have been processed.
mMainThread->SetObserver(nsnull);
mMainThread->ClearObservers();
// Release main thread object.
mMainThread = nsnull;