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
Родитель fcaaee396c
Коммит d6d23c536d
2 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -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()

Просмотреть файл

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