Bug 612551 - Clear appshell observers on xpcom-shutdown. r=blassey a=blocking-fennec

This commit is contained in:
Josh Matthews 2010-12-21 13:28:45 -08:00
parent 5144427ff0
commit a7bf9ca858
2 changed files with 23 additions and 0 deletions

View File

@ -75,6 +75,8 @@ nsIGeolocationUpdate *gLocationCallback = nsnull;
nsAppShell *nsAppShell::gAppShell = nsnull;
NS_IMPL_ISUPPORTS_INHERITED1(nsAppShell, nsBaseAppShell, nsIObserver)
nsAppShell::nsAppShell()
: mQueueLock(nsnull),
mCondLock(nsnull),
@ -114,9 +116,27 @@ nsAppShell::Init()
nsresult rv = nsBaseAppShell::Init();
if (AndroidBridge::Bridge())
AndroidBridge::Bridge()->NotifyAppShellReady();
nsCOMPtr<nsIObserverService> obsServ =
mozilla::services::GetObserverService();
if (obsServ) {
obsServ->AddObserver(this, "xpcom-shutdown", PR_FALSE);
}
return rv;
}
NS_IMETHODIMP
nsAppShell::Observe(nsISupports* aSubject,
const char* aTopic,
const PRUnichar* aData)
{
if (!strcmp(aTopic, "xpcom-shutdown")) {
// We need to ensure no observers stick around after XPCOM shuts down
// or we'll see crashes, as the app shell outlives XPConnect.
mObserversHash.Clear();
}
return nsBaseAppShell::Observe(aSubject, aTopic, aData);
}
void
nsAppShell::ScheduleNativeEventCallback()

View File

@ -61,6 +61,9 @@ public:
nsAppShell();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIOBSERVER
nsresult Init();
void NotifyNativeEvent();