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
Родитель d7c529e1a0
Коммит 4e457a4ca4
1 изменённых файлов: 13 добавлений и 10 удалений

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

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