From d4de011e307599412145c13e8f0cc5d5eee59475 Mon Sep 17 00:00:00 2001 From: "timeless@mozdev.org" Date: Tue, 11 Jan 2011 09:35:18 +0100 Subject: [PATCH] Bug 624267 - Crash on Ubuntu [@ nsGNOMEShellService::SetDefaultBrowser ] r+a=roc --- .../shell/src/nsGNOMEShellService.cpp | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/browser/components/shell/src/nsGNOMEShellService.cpp b/browser/components/shell/src/nsGNOMEShellService.cpp index 306087cb19a..e8a9de84e99 100644 --- a/browser/components/shell/src/nsGNOMEShellService.cpp +++ b/browser/components/shell/src/nsGNOMEShellService.cpp @@ -214,30 +214,31 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes, #endif nsCOMPtr gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); - - nsCAutoString appKeyValue(mAppPath); - appKeyValue.Append(" \"%s\""); - unsigned int i; - - for (i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) { - if (appProtocols[i].essential || aClaimAllTypes) { - gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name), - appKeyValue); + if (gconf) { + nsCAutoString appKeyValue(mAppPath); + appKeyValue.Append(" \"%s\""); + for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) { + if (appProtocols[i].essential || aClaimAllTypes) { + gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name), + appKeyValue); + } } } // set handler for .html and xhtml files and MIME types: if (aClaimAllTypes) { + nsresult rv; nsCOMPtr giovfs = - do_GetService(NS_GIOSERVICE_CONTRACTID); + do_GetService(NS_GIOSERVICE_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr bundleService = - do_GetService(NS_STRINGBUNDLE_CONTRACTID); - NS_ENSURE_TRUE(bundleService, NS_ERROR_OUT_OF_MEMORY); + do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr brandBundle; - bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle)); - NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE); + rv = bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle)); + NS_ENSURE_SUCCESS(rv, rv); nsString brandShortName, brandFullName; brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), @@ -247,17 +248,16 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes, // use brandShortName as the application id. NS_ConvertUTF16toUTF8 id(brandShortName); - if (giovfs) { - nsCOMPtr appInfo; - giovfs->CreateAppFromCommand(mAppPath, - id, - getter_AddRefs(appInfo)); + nsCOMPtr appInfo; + rv = giovfs->CreateAppFromCommand(mAppPath, + id, + getter_AddRefs(appInfo)); + NS_ENSURE_SUCCESS(rv, rv); - // Add mime types for html, xhtml extension and set app to just created appinfo. - for (i = 0; i < NS_ARRAY_LENGTH(appTypes); ++i) { - appInfo->SetAsDefaultForMimeType(nsDependentCString(appTypes[i].mimeType)); - appInfo->SetAsDefaultForFileExtensions(nsDependentCString(appTypes[i].extensions)); - } + // Add mime types for html, xhtml extension and set app to just created appinfo. + for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appTypes); ++i) { + appInfo->SetAsDefaultForMimeType(nsDependentCString(appTypes[i].mimeType)); + appInfo->SetAsDefaultForFileExtensions(nsDependentCString(appTypes[i].extensions)); } }