Bug 966626 - Fix for browser launch error dialog on Win8 caused by CommandExecuteHandler changes in bug 950241: release the IShellItemArray Explorer hands us prior to derefing the ceh. r=bbondy
authorJim Mathies <jmathies@mozilla.com>
Sat, 01 Feb 2014 08:03:11 -0600
changeset 166434 d09f9a9f81ae8cba40ac5a65ca0ef86d428ff802
parent 166433 7fb9722bd187e866b6de5b674cd26275919096ec
child 166445 f66e1ff54609fcb5386be739c8fe9017d27f270e
push id26124
push userjmathies@mozilla.com
push dateSat, 01 Feb 2014 14:07:34 +0000
treeherdermozilla-central@d09f9a9f81ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs966626, 950241
milestone29.0a1
first release with
nightly linux32
d09f9a9f81ae / 29.0a1 / 20140201074923 / files
nightly linux64
d09f9a9f81ae / 29.0a1 / 20140201074923 / files
nightly mac
d09f9a9f81ae / 29.0a1 / 20140201074923 / files
nightly win32
d09f9a9f81ae / 29.0a1 / 20140201074923 / files
nightly win64
d09f9a9f81ae / 29.0a1 / 20140201074923 / 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 966626 - Fix for browser launch error dialog on Win8 caused by CommandExecuteHandler changes in bug 950241: release the IShellItemArray Explorer hands us prior to derefing the ceh. r=bbondy
browser/metro/shell/commandexecutehandler/CommandExecuteHandler.cpp
--- a/browser/metro/shell/commandexecutehandler/CommandExecuteHandler.cpp
+++ b/browser/metro/shell/commandexecutehandler/CommandExecuteHandler.cpp
@@ -98,16 +98,17 @@ public:
     mRequestType(DEFAULT_LAUNCH),
     mRequestMet(false),
     mDelayedLaunchType(NONE),
     mVerb(L"open")
   {
   }
 
   bool RequestMet() { return mRequestMet; }
+  void SetRequestMet();
   long RefCount() { return mRef; }
   void HeartBeat();
 
   // IUnknown
   IFACEMETHODIMP QueryInterface(REFIID aRefID, void **aInt)
   {
     static const QITAB qit[] = {
       QITABENT(CExecuteCommandVerb, IExecuteCommand),
@@ -381,18 +382,16 @@ public:
     CStringW browserPath;
     GetDefaultBrowserPath(browserPath);
 
     return !selfPath.CompareNoCase(browserPath);
   }
 private:
   ~CExecuteCommandVerb()
   {
-    SafeRelease(&mShellItemArray);
-    SafeRelease(&mUnkSite);
   }
 
   void LaunchDesktopBrowser();
   bool LaunchMetroBrowser();
   bool SetTargetPath(IShellItem* aItem);
   bool TestForUpdateLock();
 
   /*
@@ -660,22 +659,22 @@ CExecuteCommandVerb::LaunchDesktopBrowse
 
 void
 CExecuteCommandVerb::HeartBeat()
 {
   if (mRequestType == METRO_UPDATE && mDelayedLaunchType == DESKTOP &&
       !IsMetroProcessRunning()) {
     mDelayedLaunchType = NONE;
     LaunchDesktopBrowser();
-    mRequestMet = true;
+    SetRequestMet();
   }
   if (mDelayedLaunchType == METRO && !TestForUpdateLock()) {
     mDelayedLaunchType = NONE;
     LaunchMetroBrowser();
-    mRequestMet = true;
+    SetRequestMet();
   }
 }
 
 static bool
 PrepareActivationManager(CComPtr<IApplicationActivationManager> &activateMgr)
 {
   HRESULT hr = activateMgr.CoCreateInstance(CLSID_ApplicationActivationManager,
                                             nullptr, CLSCTX_LOCAL_SERVER);
@@ -743,33 +742,31 @@ CExecuteCommandVerb::LaunchMetroBrowser(
   // protocols
   } else {
     hr = activateMgr->ActivateForProtocol(appModelID, mShellItemArray, &processID);
     Log(L"ActivateForProtocol result %X", hr);
   }
   return true;
 }
 
-class AutoSetRequestMet
+void CExecuteCommandVerb::SetRequestMet()
 {
-public:
-  explicit AutoSetRequestMet(bool* aFlag) :
-    mFlag(aFlag) {}
-  ~AutoSetRequestMet() { if (mFlag) *mFlag = true; }
-private:
-  bool* mFlag;
-};
+  SafeRelease(&mShellItemArray);
+  SafeRelease(&mUnkSite);
+  mRequestMet = true;
+  Log(L"Request met, exiting.");
+}
 
 IFACEMETHODIMP CExecuteCommandVerb::Execute()
 {
   Log(L"Execute()");
 
   if (!mTarget.GetLength()) {
     // We shut down when this flips to true
-    mRequestMet = true;
+    SetRequestMet();
     return E_FAIL;
   }
 
   // Deal with metro restart for an update - launch desktop with a command
   // that tells it to run updater then launch the metro browser.
   if (mRequestType == METRO_UPDATE) {
     // We'll complete this in the heart beat callback from the main msg loop.
     // We do this because the last browser instance makes this call to Execute
@@ -779,29 +776,29 @@ IFACEMETHODIMP CExecuteCommandVerb::Exec
     mDelayedLaunchType = DESKTOP;
     return S_OK;
   }
 
   // Launch on the desktop
   if (mRequestType == DESKTOP_RESTART ||
       (mRequestType == DEFAULT_LAUNCH && DefaultLaunchIsDesktop())) {
     LaunchDesktopBrowser();
-    mRequestMet = true;
+    SetRequestMet();
     return S_OK;
   }
 
   // If we have an update in the works, don't try to activate yet,
   // delay until the lock is removed.
   if (TestForUpdateLock()) {
     mDelayedLaunchType = METRO;
     return S_OK;
   }
 
   LaunchMetroBrowser();
-  mRequestMet = true;
+  SetRequestMet();
   return S_OK;
 }
 
 class ClassFactory : public IClassFactory 
 {
 public:
   ClassFactory(IUnknown *punkObject);
   ~ClassFactory();