diff options
Diffstat (limited to 'debian/patches/22_fix_qiconvcodec.diff')
-rw-r--r-- | debian/patches/22_fix_qiconvcodec.diff | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/debian/patches/22_fix_qiconvcodec.diff b/debian/patches/22_fix_qiconvcodec.diff new file mode 100644 index 0000000..42dad6a --- /dev/null +++ b/debian/patches/22_fix_qiconvcodec.diff @@ -0,0 +1,68 @@ +--- a/src/corelib/codecs/qiconvcodec.cpp ++++ b/src/corelib/codecs/qiconvcodec.cpp +@@ -83,6 +83,8 @@ static Ptr_iconv_close ptr_iconv_close = + + QT_BEGIN_NAMESPACE + ++extern bool qt_locale_initialized; ++ + QIconvCodec::QIconvCodec() + : utf16Codec(0) + { +@@ -182,8 +184,9 @@ QString QIconvCodec::convertToUnicode(co + } + } else { + QThreadStorage<QIconvCodec::IconvState *> *ts = toUnicodeState(); +- if (!ts) { ++ if (!qt_locale_initialized || !ts) { + // we're running after the Q_GLOBAL_STATIC has been deleted ++ // or before the QCoreApplication initialization + // bad programmer, no cookie for you + return QString::fromLatin1(chars, len); + } +@@ -305,9 +308,14 @@ QByteArray QIconvCodec::convertFromUnico + #endif + + QThreadStorage<QIconvCodec::IconvState *> *ts = fromUnicodeState(); +- if (!ts) { ++ if (!qt_locale_initialized || !ts) { + // we're running after the Q_GLOBAL_STATIC has been deleted ++ // or before the QCoreApplication initialization + // bad programmer, no cookie for you ++ if (!len) ++ // this is a special case - zero-sized string should be ++ // translated to empty but not-null QByteArray. ++ return QByteArray(""); + return QString::fromRawData(uc, len).toLatin1(); + } + IconvState *&state = ts->localData(); +@@ -384,8 +392,8 @@ QByteArray QIconvCodec::convertFromUnico + // fall through + case EINVAL: + { +- ++inBytes; +- --inBytesLeft; ++ inBytes += sizeof(QChar); ++ inBytesLeft -= sizeof(QChar); + break; + } + case E2BIG: +--- a/src/corelib/kernel/qcoreapplication.cpp ++++ b/src/corelib/kernel/qcoreapplication.cpp +@@ -163,6 +163,8 @@ void Q_CORE_EXPORT qt_call_post_routines + bool QCoreApplicationPrivate::is_app_running = false; + // app closing down if true + bool QCoreApplicationPrivate::is_app_closing = false; ++// initialized in qcoreapplication and in qtextstream autotest when setlocale is called. ++Q_AUTOTEST_EXPORT bool qt_locale_initialized = false; + + + Q_CORE_EXPORT uint qGlobalPostedEventsCount() +@@ -440,6 +442,7 @@ void QCoreApplication::init() + + #ifdef Q_OS_UNIX + setlocale(LC_ALL, ""); // use correct char set mapping ++ qt_locale_initialized = true; + #endif + + #ifdef Q_WS_WIN |