Bug 805207 - Remove static destructor from ClearOnShutdown. r=bsmedberg

This prevents the assertion added in bug 803688 from firing when we do an unclean shutdown.
This commit is contained in:
Justin Lebar 2012-10-31 13:30:35 -04:00
parent 8fc123df0d
commit eabc6a4f19
2 changed files with 10 additions and 6 deletions

View File

@ -11,7 +11,7 @@ namespace mozilla {
namespace ClearOnShutdown_Internal {
bool sHasShutDown = false;
LinkedList<ShutdownObserver> sShutdownObservers;
StaticAutoPtr<LinkedList<ShutdownObserver> > sShutdownObservers;
} // namespace ClearOnShutdown_Internal
} // namespace mozilla

View File

@ -8,6 +8,7 @@
#define mozilla_ClearOnShutdown_h
#include "mozilla/LinkedList.h"
#include "mozilla/StaticPtr.h"
#include "nsThreadUtils.h"
/*
@ -64,7 +65,7 @@ private:
};
extern bool sHasShutDown;
extern LinkedList<ShutdownObserver> sShutdownObservers;
extern StaticAutoPtr<LinkedList<ShutdownObserver> > sShutdownObservers;
} // namespace ClearOnShutdown_Internal
@ -74,10 +75,12 @@ inline void ClearOnShutdown(SmartPtr *aPtr)
using namespace ClearOnShutdown_Internal;
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!sHasShutDown);
ShutdownObserver *observer = new PointerClearer<SmartPtr>(aPtr);
sShutdownObservers.insertBack(observer);
if (!sShutdownObservers) {
sShutdownObservers = new LinkedList<ShutdownObserver>();
}
sShutdownObservers->insertBack(new PointerClearer<SmartPtr>(aPtr));
}
// Called when XPCOM is shutting down, after all shutdown notifications have
@ -89,11 +92,12 @@ inline void KillClearOnShutdown()
MOZ_ASSERT(NS_IsMainThread());
ShutdownObserver *observer;
while ((observer = sShutdownObservers.popFirst())) {
while ((observer = sShutdownObservers->popFirst())) {
observer->Shutdown();
delete observer;
}
sShutdownObservers = nullptr;
sHasShutDown = true;
}