diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-12-06 09:03:30 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-12-21 11:13:32 -0800 |
commit | a116b2ddfc9e91736b1ec4edda6500e9c8f5f301 (patch) | |
tree | 8bd237ec5aa389c379bef43f879d1ef8b72ee9d6 /src/corelib/text/qbytearray.h | |
parent | QString/QByteArray: further inline the most common indexOf operations (diff) | |
download | qtbase-a116b2ddfc9e91736b1ec4edda6500e9c8f5f301.tar.xz qtbase-a116b2ddfc9e91736b1ec4edda6500e9c8f5f301.zip |
QByteArray: allow begin() to return nullptr, like QString
That is, don't call QByteArray::data() because that one is still under
QT5_NULL_STRINGS conditional. Instead, like QString, call d.data()
directly, which is allowed to return a null pointer.
This necessitated a fix to QStringBuilder's QConcatenable because it was
iterating from &QByteArray::_empty to nullptr.
[ChangeLog][Important Behavior Changes] Calling begin() or end() in a
const QByteArray will return a null pointer if isNull() is true. This is
the same behavior as QString. This is important for code attempting to
iterate from data() to end() instead of begin() to end().
Change-Id: Ica7a43f6147b49c187ccfffd179e4cda75bd1031
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/text/qbytearray.h')
-rw-r--r-- | src/corelib/text/qbytearray.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 06d310856b..ad4264036b 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -476,7 +476,7 @@ public: typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; iterator begin() { return data(); } - const_iterator begin() const noexcept { return data(); } + const_iterator begin() const noexcept { return d.data(); } const_iterator cbegin() const noexcept { return begin(); } const_iterator constBegin() const noexcept { return begin(); } iterator end() { return begin() + size(); } |