diff --git a/content/xul/templates/src/nsXULContentUtils.cpp b/content/xul/templates/src/nsXULContentUtils.cpp index fc1fc4ca101..90cc48ccd79 100644 --- a/content/xul/templates/src/nsXULContentUtils.cpp +++ b/content/xul/templates/src/nsXULContentUtils.cpp @@ -142,26 +142,6 @@ nsXULContentUtils::Init() if (NS_FAILED(rv)) { return rv; } - - // get a locale service - nsCOMPtr localeService = - do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) { - nsCOMPtr locale; - rv = localeService->GetApplicationLocale(getter_AddRefs(locale)); - if (NS_SUCCEEDED(rv) && locale) { - nsCOMPtr colFactory = - do_CreateInstance(kCollationFactoryCID); - if (colFactory) { - rv = colFactory->CreateCollation(locale, &gCollation); - NS_ASSERTION(NS_SUCCEEDED(rv), - "couldn't create collation instance"); - } else - NS_ERROR("couldn't create instance of collation factory"); - } else - NS_ERROR("unable to get application locale"); - } else - NS_ERROR("couldn't get locale factory"); } return NS_OK; @@ -187,6 +167,35 @@ nsXULContentUtils::Finish() return NS_OK; } +nsICollation* +nsXULContentUtils::GetCollation() +{ + if (!gCollation) { + nsresult rv; + + // get a locale service + nsCOMPtr localeService = + do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv)) { + nsCOMPtr locale; + rv = localeService->GetApplicationLocale(getter_AddRefs(locale)); + if (NS_SUCCEEDED(rv) && locale) { + nsCOMPtr colFactory = + do_CreateInstance(kCollationFactoryCID); + if (colFactory) { + rv = colFactory->CreateCollation(locale, &gCollation); + NS_ASSERTION(NS_SUCCEEDED(rv), + "couldn't create collation instance"); + } else + NS_ERROR("couldn't create instance of collation factory"); + } else + NS_ERROR("unable to get application locale"); + } else + NS_ERROR("couldn't get locale factory"); + } + + return gCollation; +} //------------------------------------------------------------------------ // nsIXULContentUtils methods diff --git a/content/xul/templates/src/nsXULContentUtils.h b/content/xul/templates/src/nsXULContentUtils.h index 6839897e921..caa1f336a04 100644 --- a/content/xul/templates/src/nsXULContentUtils.h +++ b/content/xul/templates/src/nsXULContentUtils.h @@ -123,10 +123,7 @@ public: } static nsICollation* - GetCollation() - { - return gCollation; - } + GetCollation(); #define XUL_RESOURCE(ident, uri) static nsIRDFResource* ident #define XUL_LITERAL(ident, val) static nsIRDFLiteral* ident