summaryrefslogtreecommitdiffstats
path: root/tools/shared/qtpropertybrowser
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-08-30 08:51:38 (GMT)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-08-30 08:51:38 (GMT)
commit55dab21c6c139efe82228abfc9875d265ed1bd14 (patch)
treecd1bd0fe55515aa7ffabe030c5466db7259a16e4 /tools/shared/qtpropertybrowser
parent2d42128a7aad4a13b99198d13d7681c75ed568cf (diff)
downloadQt-55dab21c6c139efe82228abfc9875d265ed1bd14.zip
Qt-55dab21c6c139efe82228abfc9875d265ed1bd14.tar.gz
Qt-55dab21c6c139efe82228abfc9875d265ed1bd14.tar.bz2
Designer: Fix crash on unsupported Language/Country combination.
...in the property editor (QLocale). Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com> Task-number: QTBUG-13267 Task-number: QTCREATORBUG-2212
Diffstat (limited to 'tools/shared/qtpropertybrowser')
-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);
}
/*!