summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAhmad Samir <[email protected]>2023-06-15 02:39:19 +0300
committerAhmad Samir <[email protected]>2023-08-03 02:12:22 +0300
commit8ed2bc919432aaa2f7304b1a6207c056365cc22c (patch)
treec9ac5d58080050dff184e0fd3344dbed82043563 /src
parentd1da83002d18040f8ac21ebf6542ff71cb462509 (diff)
QByteArray: change append(QByteArray) to match QStringBuilder behavior
I.e. concatenating a null byte array and an empty-but-not-null byte array should result in an empty-but-not-null byte array. This matches the behavior of QString::append(QString) too. Fixes: QTBUG-114238 Pick-to: 6.6 Change-Id: Id36d10ee09c08041b7dabda102df48ca6d413d8b Reviewed-by: Thiago Macieira <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/text/qbytearray.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index 7f8349131d8..42921e99d76 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -2044,9 +2044,14 @@ QByteArray &QByteArray::prepend(const QByteArray &ba)
QByteArray &QByteArray::append(const QByteArray &ba)
{
- if (size() == 0 && ba.size() > d->freeSpaceAtEnd() && ba.d.isMutable())
- return (*this = ba);
- return append(QByteArrayView(ba));
+ if (!ba.isNull()) {
+ if (isNull()) {
+ operator=(ba);
+ } else if (ba.size()) {
+ append(QByteArrayView(ba));
+ }
+ }
+ return *this;
}
/*!