From 005a5d0bfeda8b1f5b4de97f0368ef6f3ad89193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 21 Jan 2010 11:38:16 +0000 Subject: [PATCH] Stumbled across some problems while using the Locale Kit and added TODOs accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35214 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/locale/Catalog.cpp | 4 ++++ src/kits/locale/Language.cpp | 2 ++ src/kits/locale/Locale.cpp | 5 ++++- src/kits/locale/LocaleRoster.cpp | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/kits/locale/Catalog.cpp b/src/kits/locale/Catalog.cpp index 6873cd379c..e93d59cf62 100644 --- a/src/kits/locale/Catalog.cpp +++ b/src/kits/locale/Catalog.cpp @@ -121,6 +121,10 @@ BCatalog::GetAppCatalog(BCatalog* catalog) appNode.ReadAttr(BLocaleRoster::kCatFingerprintAttr, B_UINT32_TYPE, 0, &fingerprint, sizeof(uint32)); // try to load catalog (with given fingerprint): + // TODO: Not so nice C++ design here, leading to such bugs: The previous + // fCatalog is leaked here. (The whole chain, it looks like.) There should + // be a SetCatalog() method (it can be private), and that should take care + // that internal members are always properly maintained. catalog->fCatalog = be_locale_roster->LoadCatalog(sig.String(), NULL, fingerprint); diff --git a/src/kits/locale/Language.cpp b/src/kits/locale/Language.cpp index 0c31758eb2..8ac5661b7f 100644 --- a/src/kits/locale/Language.cpp +++ b/src/kits/locale/Language.cpp @@ -132,6 +132,8 @@ BLanguage::GetString(uint32 id) const status_t BLanguage::GetName(BString* name) { + // TODO: This will return the language not in the current be_app_catalog, + // but in the current system wide language! Don't know the exact reason. UnicodeString s; fICULocale->getDisplayLanguage(s); BStringByteSink converter(name); diff --git a/src/kits/locale/Locale.cpp b/src/kits/locale/Locale.cpp index 8bb18f265e..1ad2bf59ab 100644 --- a/src/kits/locale/Locale.cpp +++ b/src/kits/locale/Locale.cpp @@ -45,9 +45,12 @@ BLocale::GetString(uint32 id) } status_t -BLocale::GetAppCatalog(BCatalog *catalog) { +BLocale::GetAppCatalog(BCatalog *catalog) +{ if (!catalog) return B_BAD_VALUE; + // TODO: This is not so nice, and I don't know why it is here, but how + // is it envisioned to switch languages on the fly? if (be_catalog) debugger( "GetAppCatalog() has been called while be_catalog != NULL"); return BCatalog::GetAppCatalog(catalog); diff --git a/src/kits/locale/LocaleRoster.cpp b/src/kits/locale/LocaleRoster.cpp index 1d1291ca8a..69abd879ab 100644 --- a/src/kits/locale/LocaleRoster.cpp +++ b/src/kits/locale/LocaleRoster.cpp @@ -513,6 +513,8 @@ BLocaleRoster::GetInstalledLanguages(BMessage *languages) const #undef REALLY_ALL_LANGUAGES #ifdef REALLY_ALL_LANGUAGES + // TODO: Using static variables here looks really weird, and is probably + // the reason why calling this method a second time will crash. static const char* const* icuLocaleList = Locale::getISOLanguages(); // Loop over the strings and add them to an std::set to remove duplicates