Bug 1532636 - nsObserverService should allow RemoveObserver() to be called when shutting down, r=gsvelto
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 06 Mar 2019 08:55:35 +0000
changeset 462554 8c835f11c111c813ff3471882c636949a1255453
parent 462553 35f5d2d519eb442c74d883fc88fcbc0e10b6af5b
child 462555 621207c8ef880bcee9a263fbf029fafd6a8364ea
push id79719
push useramarchesini@mozilla.com
push dateWed, 06 Mar 2019 08:57:02 +0000
treeherderautoland@8c835f11c111 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgsvelto
bugs1532636
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532636 - nsObserverService should allow RemoveObserver() to be called when shutting down, r=gsvelto Depends on D22086 Differential Revision: https://phabricator.services.mozilla.com/D22087
xpcom/ds/nsObserverService.cpp
--- a/xpcom/ds/nsObserverService.cpp
+++ b/xpcom/ds/nsObserverService.cpp
@@ -224,16 +224,21 @@ nsObserverService::AddObserver(nsIObserv
 
   return observerList->AddObserver(aObserver, aOwnsWeak);
 }
 
 NS_IMETHODIMP
 nsObserverService::RemoveObserver(nsIObserver* aObserver, const char* aTopic) {
   LOG(("nsObserverService::RemoveObserver(%p: %s)", (void*)aObserver, aTopic));
 
+  if (mShuttingDown) {
+    // The service is shutting down. Let's ignore this call.
+    return NS_OK;
+  }
+
   MOZ_TRY(EnsureValidCall());
   if (NS_WARN_IF(!aObserver) || NS_WARN_IF(!aTopic)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsObserverList* observerList = mObserverTopicTable.GetEntry(aTopic);
   if (!observerList) {
     return NS_ERROR_FAILURE;