Bug 412127: Canceling extension installation leaks nsXPITriggerInfo and nsXPITriggerItem. r=dveditz, sr=sicking
authordtownsend@oxymoronical.com
Sun, 27 Jan 2008 15:43:17 -0800
changeset 10801 7cb5ee9040ed14cab4da8a63089e240f20898876
parent 10800 9345f6a5843f357c188020b80c76c16532160a6d
child 10802 02ea9f9593b02482e260d5659f8734cadd09a74b
push idunknown
push userunknown
push dateunknown
reviewersdveditz, sicking
bugs412127
milestone1.9b3pre
Bug 412127: Canceling extension installation leaks nsXPITriggerInfo and nsXPITriggerItem. r=dveditz, sr=sicking
xpinstall/src/nsXPInstallManager.cpp
xpinstall/src/nsXPInstallManager.h
--- a/xpinstall/src/nsXPInstallManager.cpp
+++ b/xpinstall/src/nsXPInstallManager.cpp
@@ -356,24 +356,18 @@ nsXPInstallManager::InitManagerInternal(
     PRInt32 cbstatus = 0;  // callback status
     if (NS_FAILED(rv))
         cbstatus = nsInstall::UNEXPECTED_ERROR;
     else if (!OKtoInstall)
         cbstatus = nsInstall::USER_CANCELLED;
 
     if ( cbstatus != 0 )
     {
-        // --- inform callbacks of error
-        for (PRUint32 i = 0; i < mTriggers->Size(); i++)
-        {
-            mTriggers->SendStatus( mTriggers->Get(i)->mURL.get(), cbstatus );
-        }
-
-        // --- must delete ourselves if not continuing
-        NS_RELEASE_THIS();
+        // --- must shutdown if not continuing
+        Shutdown( cbstatus );
     }
 
     return rv;
 }
 
 
 NS_IMETHODIMP
 nsXPInstallManager::ConfirmInstall(nsIDOMWindow *aParent, const PRUnichar **aPackageList, PRUint32 aCount, PRBool *aRetval)
@@ -864,17 +858,17 @@ PRBool nsXPInstallManager::VerifyHash(ns
 
     PRBool result = aItem->mHash.EqualsIgnoreCase(hash);
 
     PR_smprintf_free(hash);
     return result;
 }
 
 
-void nsXPInstallManager::Shutdown()
+void nsXPInstallManager::Shutdown(PRInt32 status)
 {
     if (mDlg)
     {
         // tell the dialog it can go away
         mDlg->OnStateChange(0, nsIXPIProgressDialog::DIALOG_CLOSE, 0 );
         mDlg = nsnull;
         mDialogOpen = PR_FALSE;
     }
@@ -885,18 +879,17 @@ void nsXPInstallManager::Shutdown()
 
         // Send remaining status notifications if we were cancelled early
         nsXPITriggerItem* item;
         while ( mNextItem < mTriggers->Size() )
         {
             item = (nsXPITriggerItem*)mTriggers->Get(mNextItem++);
             if ( item && !item->mURL.IsEmpty() )
             {
-                mTriggers->SendStatus( item->mURL.get(),
-                                       nsInstall::USER_CANCELLED );
+                mTriggers->SendStatus( item->mURL.get(), status );
             }
         }
 
         // Clean up downloaded files (regular install only, not chrome installs)
         nsCOMPtr<nsIFile> tmpSpec;
         if ( mChromeType == NOT_CHROME )
         {
             for (PRUint32 i = 0; i < mTriggers->Size(); i++ )
--- a/xpinstall/src/nsXPInstallManager.h
+++ b/xpinstall/src/nsXPInstallManager.h
@@ -107,17 +107,17 @@ class nsXPInstallManager : public nsIXPI
         NS_DECL_NSIBADCERTLISTENER2
         NS_DECL_NSICHANNELEVENTSINK
 
         NS_IMETHOD InitManager(nsIDOMWindowInternal* aParentWindow, nsXPITriggerInfo* aTrigger, PRUint32 aChromeType );
 
     private:
         nsresult    InitManagerInternal();
         NS_IMETHOD  DownloadNext();
-        void        Shutdown();
+        void        Shutdown(PRInt32 status = nsInstall::USER_CANCELLED);
         NS_IMETHOD  GetDestinationFile(nsString& url, nsILocalFile* *file);
         NS_IMETHOD  LoadParams(PRUint32 aCount, const PRUnichar** aPackageList, nsIDialogParamBlock** aParams);
 #ifdef ENABLE_SKIN_SIMPLE_INSTALLATION_UI
         PRBool      ConfirmChromeInstall(nsIDOMWindowInternal* aParentWindow, const PRUnichar** aPackage);
 #endif
         PRBool      TimeToUpdate(PRTime now);
         PRBool      VerifyHash(nsXPITriggerItem* aItem);
         PRInt32     GetIndexFromURL(const PRUnichar* aUrl);