summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qtextstream.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-04 05:56:06 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-06-04 05:56:06 +0000
commitccad00121d0a9d703cf715c54347b32bfc33bbfc (patch)
tree8e492f00f9ea81d87ae9126ad06c3dbc21fee3a3 /src/corelib/io/qtextstream.cpp
parentdc2617f35be61b4827b8e3d192c85e2feacf7f6a (diff)
parente2f66f921594b7be4af4a058c959557489e86879 (diff)
Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib/io/qtextstream.cpp')
-rw-r--r--src/corelib/io/qtextstream.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 5fe4cfef9d..47b96d708f 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -464,7 +464,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
}
#if defined (QTEXTSTREAM_DEBUG)
qDebug("QTextStreamPrivate::fillReadBuffer(), using %s codec",
- codec->name().constData());
+ codec ? codec->name().constData() : "no");
#endif
#endif
@@ -476,9 +476,10 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
int oldReadBufferSize = readBuffer.size();
#ifndef QT_NO_TEXTCODEC
// convert to unicode
- readBuffer += codec->toUnicode(buf, bytesRead, &readConverterState);
+ readBuffer += Q_LIKELY(codec) ? codec->toUnicode(buf, bytesRead, &readConverterState)
+ : QString::fromLatin1(buf, bytesRead);
#else
- readBuffer += QString::fromLatin1(QByteArray(buf, bytesRead).constData());
+ readBuffer += QString::fromLatin1(buf, bytesRead);
#endif
// reset the Text flag.
@@ -564,7 +565,8 @@ void QTextStreamPrivate::flushWriteBuffer()
codec = QTextCodec::codecForLocale();
#if defined (QTEXTSTREAM_DEBUG)
qDebug("QTextStreamPrivate::flushWriteBuffer(), using %s codec (%s generating BOM)",
- codec->name().constData(), writeConverterState.flags & QTextCodec::IgnoreHeader ? "not" : "");
+ codec ? codec->name().constData() : "no",
+ !codec || (writeConverterState.flags & QTextCodec::IgnoreHeader) ? "not" : "");
#endif
// convert from unicode to raw data
@@ -572,7 +574,7 @@ void QTextStreamPrivate::flushWriteBuffer()
QByteArray data = Q_LIKELY(codec) ? codec->fromUnicode(writeBuffer.data(), writeBuffer.size(), &writeConverterState)
: writeBuffer.toLatin1();
#else
- QByteArray data = writeBuffer.toLocal8Bit();
+ QByteArray data = writeBuffer.toLatin1();
#endif
writeBuffer.clear();