diff options
| author | Ahmad Samir <a.samirh78@gmail.com> | 2023-09-05 15:01:05 +0300 |
|---|---|---|
| committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-09-10 17:50:11 +0300 |
| commit | 74098981bd42e6bc135c22506e5a910e37544406 (patch) | |
| tree | 1db00651da87b9b022f7c844b7a357bb0b2ae2b6 /src/corelib/serialization/qdatastream.cpp | |
| parent | 1849489315fc6ee8bc08c4bd0e1a0031459117e3 (diff) | |
QDataStream: clarify QDataStream::operator>>(char *&s) API docs
The wording was slightly ambiguous giving readers the idea that it will
scan for a \0 terminator in the data; however what actually happens is
that readBytes() gets the length of the string from a quint32 in the
stream right before the data, and readBytes() always adds a
null-terminator.
Fixes: QTBUG-3287
Pick-to: 6.6 6.5 6.2 5.15
Change-Id: Ie22500a9c191ffd590a6b57babeb67577c24dddb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qdatastream.cpp')
| -rw-r--r-- | src/corelib/serialization/qdatastream.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index 15b607b0e03..7bb16645c9d 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -962,10 +962,11 @@ QDataStream &QDataStream::operator>>(double &f) /*! \overload - Reads the '\\0'-terminated string \a s from the stream and returns - a reference to the stream. + Reads string \a s from the stream and returns a reference to the stream. - The string is deserialized using \c{readBytes()}. + The string is deserialized using \c{readBytes()} where the serialization + format is a \c quint32 length specifier first, followed by that many bytes + of data. The resulting string is always '\\0'-terminated. Space for the string is allocated using \c{new []} -- the caller must destroy it with \c{delete []}. |
