From 90f864a4c57c40e043978b61d85732b88dc00cc4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 12 May 2020 15:07:16 +0200 Subject: QString: remove op+=(char) and op+=(QChar::SpecialCharacter) The former messes in bad ways with the overload set (it, fatally, attracts char16_t, e.g.). The latter was probably added in response to ambiguities between (char) and (QChar). While it's harmless now, remove it, since it no longer pulls its weight. The no-ascii warning is now coming from QChar(char), so the protection isn't lost. [ChangeLog][QtCore][QString] The += operators taking char and QChar::SpecialCharacter have been removed as they cause adding a char16_t to QString to call the char overload, losing information. The append() function was not affected. Change-Id: I57116314bcc71c0d9476159513c0c10048239db3 Reviewed-by: Volker Hilsheimer Reviewed-by: Lars Knoll --- tests/auto/corelib/text/qstring/tst_qstring.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/auto/corelib/text/qstring') diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index e9bdbb41aa..4fcbc0b87e 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -447,10 +447,9 @@ private slots: void operator_pluseq_qchar_data() { operator_pluseq_data(true); } void operator_pluseq_qbytearray() { operator_pluseq_impl(); } void operator_pluseq_qbytearray_data() { operator_pluseq_data(); } - void operator_pluseq_char() { operator_pluseq_impl(); } - void operator_pluseq_char_data() { operator_pluseq_data(true); } void operator_pluseq_charstar() { operator_pluseq_impl(); } void operator_pluseq_charstar_data() { operator_pluseq_data(); } + void operator_pluseq_special_cases(); void operator_pluseq_bytearray_special_cases_data(); void operator_pluseq_bytearray_special_cases(); @@ -2703,6 +2702,17 @@ void tst_QString::append_bytearray_special_cases() } } +void tst_QString::operator_pluseq_special_cases() +{ + { + QString a; + a += QChar::CarriageReturn; + a += '\r'; + a += u'\x1111'; + QCOMPARE(a, QStringView(u"\r\r\x1111")); + } +} + void tst_QString::operator_pluseq_data(bool emptyIsNoop) { append_data(emptyIsNoop); -- cgit v1.2.3