Fix CID-2358:

* check result of BMessage::FindString() (plus more ...)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39922 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe 2010-12-22 22:44:31 +00:00
parent c905e535a2
commit 0119051c93

View File

@ -127,23 +127,29 @@ BLanguage::GetNativeName(BString& name) const
status_t
BLanguage::GetName(BString& name, const BLanguage* displayLanguage) const
{
status_t status = B_OK;
BString appLanguage;
if (displayLanguage == NULL) {
BMessage preferredLanguage;
BLocaleRoster::Default()->GetPreferredLanguages(&preferredLanguage);
preferredLanguage.FindString("language", 0, &appLanguage);
status = BLocaleRoster::Default()->GetPreferredLanguages(
&preferredLanguage);
if (status == B_OK)
status = preferredLanguage.FindString("language", 0, &appLanguage);
} else {
appLanguage = displayLanguage->Code();
}
UnicodeString string;
fICULocale->getDisplayName(Locale(appLanguage), string);
if (status == B_OK) {
UnicodeString string;
fICULocale->getDisplayName(Locale(appLanguage), string);
name.Truncate(0);
BStringByteSink converter(&name);
string.toUTF8(converter);
name.Truncate(0);
BStringByteSink converter(&name);
string.toUTF8(converter);
}
return B_OK;
return status;
}