Bug 660568 nsImageFrame::IconLoad must call Preferences::RemoveObservers() r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 03 Jun 2011 15:07:10 +0900
changeset 70492 8fff6db8b016d614084af33ea2cfaff5dcb33624
parent 70491 e05fed21ea3539bfc3b05e648556b307e8649f12
child 70499 4ae2d7ea4ba926868e4b570ba33854bc3c7afd96
push id20340
push usermasayuki@d-toybox.com
push dateFri, 03 Jun 2011 06:07:49 +0000
treeherdermozilla-central@8fff6db8b016 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs660568
milestone7.0a1
first release with
nightly linux32
8fff6db8b016 / 7.0a1 / 20110603030730 / files
nightly linux64
8fff6db8b016 / 7.0a1 / 20110603030730 / files
nightly mac
8fff6db8b016 / 7.0a1 / 20110603030730 / files
nightly win32
8fff6db8b016 / 7.0a1 / 20110603030730 / files
nightly win64
8fff6db8b016 / 7.0a1 / 20110603030224 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 660568 nsImageFrame::IconLoad must call Preferences::RemoveObservers() r=roc
layout/generic/nsImageFrame.cpp
layout/generic/nsImageFrame.h
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1887,16 +1887,30 @@ static const char* kIconLoadPrefs[] = {
 
 nsImageFrame::IconLoad::IconLoad()
 {
   // register observers
   Preferences::AddStrongObservers(this, kIconLoadPrefs);
   GetPrefs();
 }
 
+void
+nsImageFrame::IconLoad::Shutdown()
+{
+  Preferences::RemoveObservers(this, kIconLoadPrefs);
+  // in case the pref service releases us later
+  if (mLoadingImage) {
+    mLoadingImage->CancelAndForgetObserver(NS_ERROR_FAILURE);
+    mLoadingImage = nsnull;
+  }
+  if (mBrokenImage) {
+    mBrokenImage->CancelAndForgetObserver(NS_ERROR_FAILURE);
+    mBrokenImage = nsnull;
+  }
+}
 
 NS_IMETHODIMP
 nsImageFrame::IconLoad::Observe(nsISupports *aSubject, const char* aTopic,
                                 const PRUnichar* aData)
 {
   NS_ASSERTION(!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID),
                "wrong topic");
 #ifdef DEBUG
--- a/layout/generic/nsImageFrame.h
+++ b/layout/generic/nsImageFrame.h
@@ -323,28 +323,17 @@ private:
 
   class IconLoad : public nsIObserver,
                    public imgIDecoderObserver {
     // private class that wraps the data and logic needed for
     // broken image and loading image icons
   public:
     IconLoad();
 
-    void Shutdown()
-    {
-      // in case the pref service releases us later
-      if (mLoadingImage) {
-        mLoadingImage->CancelAndForgetObserver(NS_ERROR_FAILURE);
-        mLoadingImage = nsnull;
-      }
-      if (mBrokenImage) {
-        mBrokenImage->CancelAndForgetObserver(NS_ERROR_FAILURE);
-        mBrokenImage = nsnull;
-      }
-    }
+    void Shutdown();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIOBSERVER
     NS_DECL_IMGICONTAINEROBSERVER
     NS_DECL_IMGIDECODEROBSERVER
 
     void AddIconObserver(nsImageFrame *frame) {
         NS_ABORT_IF_FALSE(!mIconObservers.Contains(frame),