firefox-shell-bmo624267.patch
changeset 220 2538fd6a51be
parent 219 b20cf866bb49
child 221 488440b896fe
equal deleted inserted replaced
219:b20cf866bb49 220:2538fd6a51be
     1 # HG changeset patch
       
     2 # Parent 6c4a0e0acb3a071dbfde60e975f68f18c85bbff8
       
     3 # User timeless@mozdev.org
       
     4 Bug 624267 Crash on Ubuntu [@ nsGNOMEShellService::SetDefaultBrowser ]
       
     5 r=roc
       
     6 
       
     7 diff --git a/browser/components/shell/src/nsGNOMEShellService.cpp b/browser/components/shell/src/nsGNOMEShellService.cpp
       
     8 --- a/browser/components/shell/src/nsGNOMEShellService.cpp
       
     9 +++ b/browser/components/shell/src/nsGNOMEShellService.cpp
       
    10 @@ -214,30 +214,31 @@ nsGNOMEShellService::SetDefaultBrowser(P
       
    11  #endif
       
    12  
       
    13    nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
       
    14 -
       
    15 -  nsCAutoString appKeyValue(mAppPath);
       
    16 -  appKeyValue.Append(" \"%s\"");
       
    17 -  unsigned int i;
       
    18 -
       
    19 -  for (i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
       
    20 -    if (appProtocols[i].essential || aClaimAllTypes) {
       
    21 -      gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
       
    22 -                               appKeyValue);
       
    23 +  if (gconf) {
       
    24 +    nsCAutoString appKeyValue(mAppPath);
       
    25 +    appKeyValue.Append(" \"%s\"");
       
    26 +    for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
       
    27 +      if (appProtocols[i].essential || aClaimAllTypes) {
       
    28 +        gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
       
    29 +                                 appKeyValue);
       
    30 +      }
       
    31      }
       
    32    }
       
    33  
       
    34    // set handler for .html and xhtml files and MIME types:
       
    35    if (aClaimAllTypes) {
       
    36 +    nsresult rv;
       
    37      nsCOMPtr<nsIGIOService> giovfs =
       
    38 -      do_GetService(NS_GIOSERVICE_CONTRACTID);
       
    39 +      do_GetService(NS_GIOSERVICE_CONTRACTID, &rv);
       
    40 +    NS_ENSURE_SUCCESS(rv, rv);
       
    41  
       
    42      nsCOMPtr<nsIStringBundleService> bundleService =
       
    43 -      do_GetService(NS_STRINGBUNDLE_CONTRACTID);
       
    44 -    NS_ENSURE_TRUE(bundleService, NS_ERROR_OUT_OF_MEMORY);
       
    45 +      do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
       
    46 +    NS_ENSURE_SUCCESS(rv, rv);
       
    47  
       
    48      nsCOMPtr<nsIStringBundle> brandBundle;
       
    49 -    bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle));
       
    50 -    NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE);
       
    51 +    rv = bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle));
       
    52 +    NS_ENSURE_SUCCESS(rv, rv);
       
    53  
       
    54      nsString brandShortName, brandFullName;
       
    55      brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
       
    56 @@ -247,17 +248,16 @@ nsGNOMEShellService::SetDefaultBrowser(P
       
    57  
       
    58      // use brandShortName as the application id.
       
    59      NS_ConvertUTF16toUTF8 id(brandShortName);
       
    60 -    if (giovfs) {
       
    61 -      nsCOMPtr<nsIGIOMimeApp> appInfo;
       
    62 -      giovfs->CreateAppFromCommand(mAppPath,
       
    63 -                                id,
       
    64 -                                getter_AddRefs(appInfo));
       
    65 +    nsCOMPtr<nsIGIOMimeApp> appInfo;
       
    66 +    rv = giovfs->CreateAppFromCommand(mAppPath,
       
    67 +                                      id,
       
    68 +                                      getter_AddRefs(appInfo));
       
    69 +    NS_ENSURE_SUCCESS(rv, rv);
       
    70  
       
    71 -      // Add mime types for html, xhtml extension and set app to just created appinfo.
       
    72 -      for (i = 0; i < NS_ARRAY_LENGTH(appTypes); ++i) {
       
    73 -        appInfo->SetAsDefaultForMimeType(nsDependentCString(appTypes[i].mimeType));
       
    74 -        appInfo->SetAsDefaultForFileExtensions(nsDependentCString(appTypes[i].extensions));
       
    75 -      }
       
    76 +    // Add mime types for html, xhtml extension and set app to just created appinfo.
       
    77 +    for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appTypes); ++i) {
       
    78 +      appInfo->SetAsDefaultForMimeType(nsDependentCString(appTypes[i].mimeType));
       
    79 +      appInfo->SetAsDefaultForFileExtensions(nsDependentCString(appTypes[i].extensions));
       
    80      }
       
    81    }
       
    82