Bug 869083 - Fix OS X apps code to return failure on failure to launch app. r=felipc, r=smichaud
authorJosh Aas <joshmoz@gmail.com>
Fri, 02 Aug 2013 08:06:22 -0400
changeset 140963 8e0fdcc3626199a8f3bc0bc07994c80911acdcd8
parent 140962 fa4afb7214aefb84ef276b7d2f01911d9be25b55
child 140964 607a23f631fe580b6eda164de4a1f76d1f863c36
push id2011
push userryanvm@gmail.com
push dateFri, 02 Aug 2013 12:06:48 +0000
treeherderfx-team@607a23f631fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipc, smichaud
bugs869083
milestone25.0a1
Bug 869083 - Fix OS X apps code to return failure on failure to launch app. r=felipc, r=smichaud
toolkit/webapps/WebappOSUtils.jsm
widget/cocoa/nsMacWebAppUtils.mm
--- a/toolkit/webapps/WebappOSUtils.jsm
+++ b/toolkit/webapps/WebappOSUtils.jsm
@@ -44,20 +44,24 @@ this.WebappOSUtils = {
 #elifdef XP_MACOSX
     let mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]
                     .createInstance(Ci.nsIMacWebAppUtils);
     let appPath;
     try {
       appPath = mwaUtils.pathForAppWithIdentifier(aData.origin);
     } catch (e) {}
 
-    if (appPath) {
+    if (!appPath) {
+      return false;
+    }
+
+    try {
       mwaUtils.launchAppWithIdentifier(aData.origin);
       return true;
-    }
+    } catch (e) {}
 
     return false;
 #elifdef XP_UNIX
     let origin = Services.io.newURI(aData.origin, null, null);
     let installDir = "." + origin.scheme + ";" +
                      origin.host +
                      (origin.port != -1 ? ";" + origin.port : "");
 
--- a/widget/cocoa/nsMacWebAppUtils.mm
+++ b/widget/cocoa/nsMacWebAppUtils.mm
@@ -18,43 +18,40 @@
 
 NS_IMPL_ISUPPORTS1(nsMacWebAppUtils, nsIMacWebAppUtils)
 
 NS_IMETHODIMP nsMacWebAppUtils::PathForAppWithIdentifier(const nsAString& bundleIdentifier, nsAString& outPath) {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   outPath.Truncate();
 
-  NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
+  nsAutoreleasePool localPool;
 
   //note that the result of this expression might be nil, meaning no matching app was found. 
   NSString* temp = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:
                         [NSString stringWithCharacters:((nsString)bundleIdentifier).get() length:((nsString)bundleIdentifier).Length()]];
 
   if (temp) {
     // Copy out the resultant absolute path into outPath if non-nil.
     nsCocoaUtils::GetStringForNSString(temp, outPath);
   }
 
-  [ap release];
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsMacWebAppUtils::LaunchAppWithIdentifier(const nsAString& bundleIdentifier) {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
-  NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
+  nsAutoreleasePool localPool;
 
   // Note this might return false, meaning the app wasnt launched for some reason. 
   BOOL success = [[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:
                         [NSString stringWithCharacters:((nsString)bundleIdentifier).get() length:((nsString)bundleIdentifier).Length()]
                         options: (NSWorkspaceLaunchOptions)0
                         additionalEventParamDescriptor: nil
                         launchIdentifier: NULL];
 
-
-  [ap release];
-  return NS_OK;
+  return success ? NS_OK : NS_ERROR_FAILURE;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }