diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-05-12 03:33:50 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-16 04:25:14 +0200 |
commit | b25b3a9f8bee10d490d3160d1fb28bf0013c8e0b (patch) | |
tree | 0dc6ece26193cbc111789f639e7f8ac78796f4be /src/corelib/codecs/qiconvcodec.cpp | |
parent | 1756a84756807a9849aa507e77845dfdf31b8020 (diff) |
Avoid using iconv for text conversion where possible
Try to use a builtin codec as codecForLocale() if possible
first. Fall back and instantiate the iconv codec only
if that failed.
In addition, make sure we initialize the locale correctly
before we try to setup the codec.
Change-Id: I86d635f9d11e8ff93093f162e79fb37f3d85731b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/codecs/qiconvcodec.cpp')
-rw-r--r-- | src/corelib/codecs/qiconvcodec.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index be22ff9bca..84a8e8d39d 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -88,8 +88,6 @@ static Ptr_iconv_close ptr_iconv_close = 0; QT_BEGIN_NAMESPACE -extern bool qt_locale_initialized; - QIconvCodec::QIconvCodec() : utf16Codec(0) { @@ -190,7 +188,7 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState } } else { QThreadStorage<QIconvCodec::IconvState *> *ts = toUnicodeState(); - if (!qt_locale_initialized || !ts) { + if (!ts) { // we're running after the Q_GLOBAL_STATIC has been deleted // or before the QCoreApplication initialization // bad programmer, no cookie for you @@ -346,7 +344,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt IconvState *temporaryState = 0; QThreadStorage<QIconvCodec::IconvState *> *ts = fromUnicodeState(); - IconvState *&state = (qt_locale_initialized && ts) ? ts->localData() : temporaryState; + IconvState *&state = ts ? ts->localData() : temporaryState; if (!state) { iconv_t cd = QIconvCodec::createIconv_t(0, UTF16); if (cd != reinterpret_cast<iconv_t>(-1)) { |