qt5base-lts/tests/auto/corelib/tools/qstring
Marc Mutz 6f145707eb QString::from{Utf8,Latin1,Local8Bit}(QByteArray): preserve nullness of argument
Currently, calling these functions with a null QByteArray will return
a non-null QString because QByteArray::data() never returns nullptr.

This behavior leads to inconsistencies between QString::append overloads,
in particular the QByteArray vs. all others (null + null test always
returns a null QString, except for the QByteArray overload before this
change).

It also is inconsistent with the const char* overloads of these methods,
which explicitly preserve nullness (as verified by test cases).

Fixed by an explicit check for nullness and return of null QString.

Alternative would have been to check for nullness and pass nullptr
instead of ba.data() to the _helper() functions, which do the correct
thing in that case. But since we'd have the check anyway and with the
chosen strategy we can avoid a call to a non-inline method, I opted
against that.

[ChangeLog][QtCore][QString] fromLatin1(), fromAscii(), fromUtf8() and
fromLocal8Bit() now return a null QString when called with a null
QByteArray.

Change-Id: I5f2c0bad27fb73c7d535085af0271823bf6ed1da
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-04-02 19:28:18 +00:00
..
.gitignore Moving relevant tests to corelib/tools 2011-09-01 13:07:23 +02:00
double_data.h Update copyright headers 2015-02-11 06:49:51 +00:00
qstring.pro Add conversion functions for C++11 u16string and u32string 2015-01-24 11:50:13 +01:00
tst_qstring_mac.mm Fixed license headers 2015-02-17 18:46:09 +00:00
tst_qstring.cpp QString::from{Utf8,Latin1,Local8Bit}(QByteArray): preserve nullness of argument 2015-04-02 19:28:18 +00:00