diff options
author | Lars Knoll <lars.knoll@qt.io> | 2019-11-16 23:25:26 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-07-06 21:29:58 +0200 |
commit | 76004502baa118016c8e0f32895af7a822f1ba37 (patch) | |
tree | 3fb524e333cb2edf6e983c4898c76f9eebb04eb4 /tests/auto/corelib/text/qstring/tst_qstring.cpp | |
parent | 2e51686746c45055e5bb74f58e0c159bfb6a8c13 (diff) |
Get rid of shared null for QByteArray, QString and QVector
As a side effect, data() can now return a nullptr. This
has the potential to cause crashes in existig code. To work
around this, return an empty string from QString::data()
and QByteArray::data() for now.
For Qt 6 (and once all our internal issues are fixed), data()
will by default return a nullptr for a null QString, but we'll
offer a #define to enable backwards compatible behavior.
Change-Id: I4f66d97ff1dce3eb99a239f1eab9106fa9b1741a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/text/qstring/tst_qstring.cpp')
-rw-r--r-- | tests/auto/corelib/text/qstring/tst_qstring.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 81a08eb59e..4d2e91a694 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -4014,7 +4014,7 @@ void tst_QString::fromRawData() { const QChar ptr[] = { 0x1234, 0x0000 }; QString cstr = QString::fromRawData(ptr, 1); - QVERIFY(cstr.isDetached()); + QVERIFY(!cstr.isDetached()); QVERIFY(cstr.constData() == ptr); QVERIFY(cstr == QString(ptr, 1)); cstr.squeeze(); @@ -4036,7 +4036,7 @@ void tst_QString::setRawData() // This just tests the fromRawData() fallback QVERIFY(!cstr.isDetached()); cstr.setRawData(ptr, 1); - QVERIFY(cstr.isDetached()); + QVERIFY(!cstr.isDetached()); QVERIFY(cstr.constData() == ptr); QVERIFY(cstr == QString(ptr, 1)); @@ -6571,7 +6571,7 @@ void tst_QString::literals() QVERIFY(str.length() == 4); QCOMPARE(str.capacity(), 0); QVERIFY(str == QLatin1String("abcd")); - QVERIFY(str.data_ptr()->isStatic()); + QVERIFY(!str.data_ptr()->isMutable()); const QChar *s = str.constData(); QString str2 = str; |