summaryrefslogtreecommitdiffstats
path: root/tools/shared
diff options
context:
space:
mode:
Diffstat (limited to 'tools/shared')
-rw-r--r--tools/shared/qtpropertybrowser/qtpropertymanager.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
index d9ff10a..a0bef0a 100644
--- a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
+++ b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
@@ -2399,15 +2399,23 @@ QString QtLocalePropertyManager::valueText(const QtProperty *property) const
if (it == d_ptr->m_values.constEnd())
return QString();
- QLocale loc = it.value();
+ const QLocale loc = it.value();
int langIdx = 0;
int countryIdx = 0;
- metaEnumProvider()->localeToIndex(loc.language(), loc.country(), &langIdx, &countryIdx);
- QString str = tr("%1, %2")
- .arg(metaEnumProvider()->languageEnumNames().at(langIdx))
- .arg(metaEnumProvider()->countryEnumNames(loc.language()).at(countryIdx));
- return str;
+ const QtMetaEnumProvider *me = metaEnumProvider();
+ me->localeToIndex(loc.language(), loc.country(), &langIdx, &countryIdx);
+ if (langIdx < 0) {
+ qWarning("QtLocalePropertyManager::valueText: Unknown language %d", loc.language());
+ return tr("<Invalid>");
+ }
+ const QString languageName = me->languageEnumNames().at(langIdx);
+ if (countryIdx < 0) {
+ qWarning("QtLocalePropertyManager::valueText: Unknown country %d for %s", loc.country(), qPrintable(languageName));
+ return languageName;
+ }
+ const QString countryName = me->countryEnumNames(loc.language()).at(countryIdx);
+ return tr("%1, %2").arg(languageName, countryName);
}
/*!