QString/QByteArray::op>>: don't assume clear() makes the container isNull()
This is something we may want to change at some point, so be explicit and assign a null container instead of relying on clear(). Add a comment that was present in the QString, but missing in the QByteArray implementation. Task-number: QTBUG-31283 Task-number: QTBUG-60745 Change-Id: I10d82b8a0c67fff314af526c7b7e0f247c3405fd Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> (cherry picked from commit 038c1c5978c30675c5f953035a193bc76ca6ca21) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
ddc6eddf77
commit
a151f3461c
@ -3229,8 +3229,10 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba)
|
||||
ba.clear();
|
||||
quint32 len;
|
||||
in >> len;
|
||||
if (len == 0xffffffff)
|
||||
if (len == 0xffffffff) { // null byte-array
|
||||
ba = QByteArray();
|
||||
return in;
|
||||
}
|
||||
|
||||
const quint32 Step = 1024 * 1024;
|
||||
quint32 allocated = 0;
|
||||
|
@ -10432,7 +10432,7 @@ QDataStream &operator>>(QDataStream &in, QString &str)
|
||||
quint32 bytes = 0;
|
||||
in >> bytes; // read size of string
|
||||
if (bytes == 0xffffffff) { // null string
|
||||
str.clear();
|
||||
str = QString();
|
||||
} else if (bytes > 0) { // not empty
|
||||
if (bytes & 0x1) {
|
||||
str.clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user