Bug 578890. Stop leaking shutdown observers from prefbranches. r=bsmedberg
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 04 Nov 2010 16:06:05 -0400
changeset 56858 493fe7f156e50eaa94ff460ededaeb98f7fab60b
parent 56854 f7016571b4726d9f465ef4b698f0e9e88adaa3ea
child 56859 4467f70ed6df12458caef94de28c7502557d97f6
push id16716
push userbzbarsky@mozilla.com
push dateThu, 04 Nov 2010 20:06:47 +0000
treeherdermozilla-central@c0dbdafa583c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs578890
milestone2.0b8pre
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 578890. Stop leaking shutdown observers from prefbranches. r=bsmedberg
modules/libpref/src/nsPrefBranch.cpp
--- a/modules/libpref/src/nsPrefBranch.cpp
+++ b/modules/libpref/src/nsPrefBranch.cpp
@@ -111,16 +111,21 @@ nsPrefBranch::nsPrefBranch(const char *a
     observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
     --mRefCnt;
   }
 }
 
 nsPrefBranch::~nsPrefBranch()
 {
   freeObserverList();
+
+  nsCOMPtr<nsIObserverService> observerService =
+    mozilla::services::GetObserverService();
+  if (observerService)
+    observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
 }
 
 
 /*
  * nsISupports Implementation
  */
 
 NS_IMPL_THREADSAFE_ADDREF(nsPrefBranch)