Bug 538310, clean up old mimetype code, r=jst, sr=sicking
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 11 Feb 2010 13:03:47 +0200
changeset 38058 0068be50163313a2172ed974009d29c6818acab1
parent 38057 d532977c11bf7257c5c3ea7f0d1aaf2a880ccf48
child 38059 b6a6b5a1f048efed2c98f9b53c6dcad749b71b8f
push id11594
push useropettay@mozilla.com
push dateThu, 11 Feb 2010 11:13:20 +0000
treeherdermozilla-central@0068be501633 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst, sicking
bugs538310
milestone1.9.3a2pre
Bug 538310, clean up old mimetype code, r=jst, sr=sicking
dom/base/nsMimeTypeArray.h
dom/base/nsPluginArray.cpp
--- a/dom/base/nsMimeTypeArray.h
+++ b/dom/base/nsMimeTypeArray.h
@@ -97,16 +97,18 @@ class nsMimeType : public nsIDOMMimeType
 {
 public:
   nsMimeType(nsIDOMPlugin* aPlugin, nsIDOMMimeType* aMimeType);
   virtual ~nsMimeType();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMMIMETYPE
 
+  void DetachPlugin() { mPlugin = nsnull; }
+
 protected:
   nsIDOMPlugin* mPlugin;
   nsCOMPtr<nsIDOMMimeType> mMimeType;
 };
 
 class nsHelperMimeType : public nsIDOMMimeType
 {
 public:
--- a/dom/base/nsPluginArray.cpp
+++ b/dom/base/nsPluginArray.cpp
@@ -280,18 +280,23 @@ nsPluginElement::nsPluginElement(nsIDOMP
   mMimeTypeArray = nsnull;
 }
 
 nsPluginElement::~nsPluginElement()
 {
   NS_IF_RELEASE(mPlugin);
 
   if (mMimeTypeArray != nsnull) {
-    for (PRUint32 i = 0; i < mMimeTypeCount; i++)
-      NS_IF_RELEASE(mMimeTypeArray[i]);
+    for (PRUint32 i = 0; i < mMimeTypeCount; i++) {
+      nsMimeType* mt = static_cast<nsMimeType*>(mMimeTypeArray[i]);
+      if (mt) {
+        mt->DetachPlugin();
+        NS_RELEASE(mt);
+      }
+    }
     delete[] mMimeTypeArray;
   }
 }
 
 
 // QueryInterface implementation for nsPluginElement
 NS_INTERFACE_MAP_BEGIN(nsPluginElement)
   NS_INTERFACE_MAP_ENTRY(nsISupports)