Bug 1221279 Don't crash while clearing imgLoader cache when disconnected document is destroyed. r=smaug

This commit is contained in:
Ben Kelly 2015-11-04 08:26:46 -08:00
parent 67758796f9
commit 31e57f37fa

View File

@ -8894,16 +8894,6 @@ nsDocument::Destroy()
mRegistry = nullptr;
using mozilla::dom::workers::ServiceWorkerManager;
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
if (swm) {
ErrorResult error;
if (swm->IsControlled(this, error)) {
nsContentUtils::GetImgLoaderForDocument(this)->ClearCacheForControlledDocument(this);
}
swm->MaybeStopControlling(this);
}
// XXX We really should let cycle collection do this, but that currently still
// leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684).
ReleaseWrapper(static_cast<nsINode*>(this));
@ -8915,6 +8905,19 @@ nsDocument::RemovedFromDocShell()
if (mRemovedFromDocShell)
return;
using mozilla::dom::workers::ServiceWorkerManager;
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
if (swm) {
ErrorResult error;
if (swm->IsControlled(this, error)) {
imgLoader* loader = nsContentUtils::GetImgLoaderForDocument(this);
if (loader) {
loader->ClearCacheForControlledDocument(this);
}
}
swm->MaybeStopControlling(this);
}
mRemovedFromDocShell = true;
EnumerateActivityObservers(NotifyActivityChanged, nullptr);