Bug 259688: Crash [@nsCOMPtr_base::~nsCOMPtr_base] [@ 0x003a0043] installing themes and extensions. r+sr=dveditz
authordtownsend@oxymoronical.com
Sun, 30 Sep 2007 06:06:54 -0700
changeset 6454 0287f35c49fb776b39300140056a20f5fffed70a
parent 6453 b5f8f1cbd31dcb0e5ee22d4e4458535704f1b451
child 6455 0b8d86506856b4cdf7da4a648258e4a2b0cefe7d
push idunknown
push userunknown
push dateunknown
bugs259688
milestone1.9a9pre
Bug 259688: Crash [@nsCOMPtr_base::~nsCOMPtr_base] [@ 0x003a0043] installing themes and extensions. r+sr=dveditz
xpinstall/src/nsXPInstallManager.cpp
--- a/xpinstall/src/nsXPInstallManager.cpp
+++ b/xpinstall/src/nsXPInstallManager.cpp
@@ -116,20 +116,16 @@ nsXPInstallManager::nsXPInstallManager()
     mSelectChrome(PR_FALSE), mNeedsShutdown(PR_FALSE), mFromChrome(PR_FALSE)
 {
     // we need to own ourself because we have a longer
     // lifetime than the scriptlet that created us.
     NS_ADDREF_THIS();
 
     // initialize mLastUpdate to the current time
     mLastUpdate = PR_Now();
-
-    nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
-    if (os)
-        os->AddObserver(this, XPI_PROGRESS_TOPIC, PR_TRUE);
 }
 
 
 nsXPInstallManager::~nsXPInstallManager()
 {
     if (mTriggers)
         delete mTriggers;
 }
@@ -173,16 +169,20 @@ nsXPInstallManager::InitManagerWithHashe
         return NS_OK;
   
     mTriggers = new nsXPITriggerInfo();
     if (!mTriggers)
         return NS_ERROR_OUT_OF_MEMORY;
 
     mNeedsShutdown = PR_TRUE;
 
+    nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
+    if (os)
+        os->AddObserver(this, XPI_PROGRESS_TOPIC, PR_TRUE);
+
     for (PRUint32 i = 0; i < aURLCount; ++i) 
     {
         nsXPITriggerItem* item = new nsXPITriggerItem(0, aURLs[i], nsnull,
                                                       aHashes ? aHashes[i] : nsnull);
         if (!item)
         {
             delete mTriggers; // nsXPITriggerInfo frees any alloc'ed nsXPITriggerItems
             mTriggers = nsnull;
@@ -336,16 +336,20 @@ nsXPInstallManager::InitManagerInternal(
             if (NS_FAILED(rv))
                 OKtoInstall = PR_FALSE;
 #ifdef ENABLE_SKIN_SIMPLE_INSTALLATION_UI
         }
 #endif
 
         if (OKtoInstall)
         {
+            nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
+            if (os)
+                os->AddObserver(this, XPI_PROGRESS_TOPIC, PR_TRUE);
+
             //-----------------------------------------------------
             // Open the progress dialog
             //-----------------------------------------------------
 
             rv = dlgSvc->OpenProgressDialog( packageList, numStrings, this );
         }
     }
     else