diff options
author | David Schulz <david.schulz@qt.io> | 2018-12-11 10:24:54 +0100 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2018-12-12 11:13:43 +0000 |
commit | c773fabc06f47678d51363f94709653752460974 (patch) | |
tree | 09e6a4305b92b1f579c05161b3271498eba1e2d7 /src/plugins/coreplugin/editormanager | |
parent | 1934119c427078be2ac4e39bf2ba039429a78984 (diff) | |
download | qt-creator-c773fabc06f47678d51363f94709653752460974.tar.gz |
Core: Fix using system codec
Qt5 doesn't return a valid codec when looking up the "System" codec, but
will return such a codec when asking for the codec for locale and no
matching codec is available. So check whether this system codec was
saved to the settings.
Task-number: QTCREATORBUG-21622
Change-Id: I4dc3ab47a3a54f7e4ad4e00004c2622b26182db3
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/coreplugin/editormanager')
-rw-r--r-- | src/plugins/coreplugin/editormanager/editormanager.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 5c8f39747d..5c91901eab 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -3040,9 +3040,16 @@ void EditorManager::hideEditorStatusBar(const QString &id) QTextCodec *EditorManager::defaultTextCodec() { QSettings *settings = ICore::settings(); - if (QTextCodec *candidate = QTextCodec::codecForName( - settings->value(Constants::SETTINGS_DEFAULTTEXTENCODING).toByteArray())) + const QByteArray codecName = + settings->value(Constants::SETTINGS_DEFAULTTEXTENCODING).toByteArray(); + if (QTextCodec *candidate = QTextCodec::codecForName(codecName)) return candidate; + // Qt5 doesn't return a valid codec when looking up the "System" codec, but will return + // such a codec when asking for the codec for locale and no matching codec is available. + // So check whether such a codec was saved to the settings. + QTextCodec *localeCodec = QTextCodec::codecForLocale(); + if (codecName == localeCodec->name()) + return localeCodec; if (QTextCodec *defaultUTF8 = QTextCodec::codecForName("UTF-8")) return defaultUTF8; return QTextCodec::codecForLocale(); |