From 9c8a8e90a6514c23bcbeb14073a9d6bdd926d68b Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Mon, 11 Jul 2016 17:23:21 +0300 Subject: QString: fix append(const QStringRef &str) Use QStringRef::isNull instead of QStringRef::string() for validation. Non-NULL str.string() may yet leave us with a useless str.unicode(), which is the actual problem here; whereas !str.isNull() does really confirm that str.unicode() is sensible. Such test prevents situation like: const QString a; QString b; b.append(a); // b.isNull() == true b.append(QStringRef(&a)); // b.isNull() == false Auto test updated: create QStringRef from QString directly, without any condition. Change-Id: I082cd58ef656d8a53e3c1223aca01feea82fffb9 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/corelib/tools/qstring/tst_qstring.cpp') diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index da6cdddd4f..db4c33afde 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -131,7 +131,7 @@ template <> class Arg : ArgBase { QStringRef ref() const - { return this->pinned.isNull() ? QStringRef() : this->pinned.midRef(0) ; } + { return QStringRef(&pinned); } public: explicit Arg(const char *str) : ArgBase(str) {} -- cgit v1.2.3