summaryrefslogtreecommitdiffstats
path: root/src/corelib/mimetypes/qmimetype.cpp
diff options
context:
space:
mode:
authorGary Wang <wzc782970009@gmail.com>2018-10-23 14:17:29 +0800
committerGary Wang <wzc782970009@gmail.com>2018-11-02 08:27:10 +0000
commite3c84b6da1cbef7ed779ba5eec6ae3ed8e4e5d59 (patch)
tree03b028eca33c3b71f1bbaa80d202f40472a432c3 /src/corelib/mimetypes/qmimetype.cpp
parent8637235e855ef9ad88aa56404a1d16387610e227 (diff)
QMimeType: Use default key as fallback for comment() property
When QMimeProvider parses the shared mime database xml files, it will read the <comment> element for mime comment and treat the `xml:lang` attribute as locale language string. When no `xml:lang` attr is provided, QMimeProvider will read the value and treat it as a en_US locale string as the default key. When we call QMimeType::comment(), it will try to get the locale comment string with the default language (QLocale().name()), once it can't find a matched result, it should return the default key (which QMimeProvider set it as en_US locale before) as fallback. Task-number: QTBUG-71314 Change-Id: I444f8159d6f19dfef6338cd79312f608d8f13394 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/mimetypes/qmimetype.cpp')
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index 50b8eae5c3..55c7de0c87 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -258,6 +258,7 @@ QString QMimeType::comment() const
QStringList languageList;
languageList << QLocale().name();
languageList << QLocale().uiLanguages();
+ languageList << QLatin1String("default"); // use the default locale if possible.
for (const QString &language : qAsConst(languageList)) {
const QString lang = language == QLatin1String("C") ? QLatin1String("en_US") : language;
const QString comm = d->localeComments.value(lang);