Bug 1277405: Clear Places observers at XPCOM shutdown. r=mak

MozReview-Commit-ID: 6JYMX7TXDLZ

--HG--
extra : rebase_source : e3828d8cc57246ef2633dc7d7ef7145437f2ebf6
extra : amend_source : 702d193f2cb0ad02a578bc4b07b9ea94e43f2ce6
This commit is contained in:
Kris Maglione 2016-06-01 16:47:34 -07:00
parent 016ce0a996
commit 0c9d76f23e
2 changed files with 12 additions and 3 deletions

View File

@ -2522,6 +2522,10 @@ nsNavBookmarks::AddObserver(nsINavBookmarkObserver* aObserver,
bool aOwnsWeak)
{
NS_ENSURE_ARG(aObserver);
if (NS_WARN_IF(!mCanNotify))
return NS_ERROR_UNEXPECTED;
return mObservers.AppendWeakElement(aObserver, aOwnsWeak);
}
@ -2634,6 +2638,7 @@ nsNavBookmarks::Observe(nsISupports *aSubject, const char *aTopic,
// Don't even try to notify observers from this point on, the category
// cache would init services that could try to use our APIs.
mCanNotify = false;
mObservers.Clear();
}
return NS_OK;

View File

@ -2250,6 +2250,9 @@ nsNavHistory::AddObserver(nsINavHistoryObserver* aObserver, bool aOwnsWeak)
NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
NS_ENSURE_ARG(aObserver);
if (NS_WARN_IF(!mCanNotify))
return NS_ERROR_UNEXPECTED;
return mObservers.AppendWeakElement(aObserver, aOwnsWeak);
}
@ -3087,9 +3090,10 @@ nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic,
}
else if (strcmp(aTopic, TOPIC_PLACES_CONNECTION_CLOSED) == 0) {
// Don't even try to notify observers from this point on, the category
// cache would init services that could try to use our APIs.
mCanNotify = false;
// Don't even try to notify observers from this point on, the category
// cache would init services that could try to use our APIs.
mCanNotify = false;
mObservers.Clear();
}
#ifdef MOZ_XUL