diff options
author | Liang Qi <liang.qi@qt.io> | 2017-02-17 20:10:34 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-02-17 20:10:34 +0100 |
commit | bc4cd465dd5df82e13f3c7709166ee11289d219f (patch) | |
tree | d6323aaed6383e589fbefb6057648c22bb187c76 /src/corelib/tools/qstring.cpp | |
parent | 43daefb0962794b2df256cae1098e889b9b36f12 (diff) | |
parent | 07745d7bfbf6c8d83e0243150d8ce934675dea87 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
qmake/Makefile.unix
Change-Id: Ia18e391198222eef34ffa2df6f683e052058d032
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 5da45181d9..8e7f0e50d3 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -4635,6 +4635,8 @@ QByteArray QString::toLatin1_helper_inplace(QString &s) QByteArray QString::toLocal8Bit_helper(const QChar *data, int size) { + if (!data) + return QByteArray(); #ifndef QT_NO_TEXTCODEC QTextCodec *localeCodec = QTextCodec::codecForLocale(); if (localeCodec) @@ -10394,6 +10396,8 @@ static inline bool qt_ends_with(const QChar *haystack, int haystackLen, */ QByteArray QStringRef::toLatin1() const { + if (isNull()) + return QByteArray(); return QString::toLatin1_helper(unicode(), length()); } @@ -10432,9 +10436,11 @@ QByteArray QStringRef::toLatin1() const QByteArray QStringRef::toLocal8Bit() const { #ifndef QT_NO_TEXTCODEC - QTextCodec *localeCodec = QTextCodec::codecForLocale(); - if (localeCodec) - return localeCodec->fromUnicode(unicode(), length()); + if (!isNull()) { + QTextCodec *localeCodec = QTextCodec::codecForLocale(); + if (localeCodec) + return localeCodec->fromUnicode(unicode(), length()); + } #endif // QT_NO_TEXTCODEC return toLatin1(); } |