From f89bf2c15354729c5615209588c235e5eb311c0f Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 21 Mar 2012 10:03:26 +0100 Subject: [PATCH] Make comment() work in the C locale too. The parser makes the default language en_US, and no mimetype xml says , so use the en_US string for the C locale, rather than returning an empty string. Change-Id: Iad7c142e8078abe357773249416e7ce9b3e29a92 Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimetype.cpp | 3 ++- .../auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp index 18ce5e5000..ea10cbe70a 100644 --- a/src/corelib/mimetypes/qmimetype.cpp +++ b/src/corelib/mimetypes/qmimetype.cpp @@ -282,7 +282,8 @@ QString QMimeType::comment() const QStringList languageList; languageList << QLocale::system().name(); languageList << QLocale::system().uiLanguages(); - Q_FOREACH (const QString &lang, languageList) { + Q_FOREACH (const QString &language, languageList) { + const QString lang = language == QLatin1String("C") ? QLatin1String("en_US") : language; const QString comm = d->localeComments.value(lang); if (!comm.isEmpty()) return comm; diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 9076f37c7c..ecea1a927e 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -56,7 +56,7 @@ static const char yastFileName[] ="yast2-metapackage-handler-mimetypes.xml"; void initializeLang() { qputenv("LC_ALL", ""); - qputenv("LANG", "en_US"); + qputenv("LANG", "C"); QCoreApplication::setApplicationName("tst_qmimedatabase"); // temporary directory pattern }