diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-07-03 16:03:54 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2021-07-06 14:50:55 +0300 |
commit | 03272e601ce0b03c36717dac0a60c2fdd8987bee (patch) | |
tree | 37cef825c04c7029ec05f7f64213ddf83b05bf27 /src/corelib/io/qiodevice.cpp | |
parent | d9a9eca54d72583ec03caedc10f83e080a20b031 (diff) |
Clarify readLine() behavior on sequential devices
QIODevice::readLine() can also return partial lines, which was not
properly documented. Add an autotest for QLocalSocket to illustrate
and test this behavior.
Pick-to: 6.2
Change-Id: Ia2c1c438cc68d2672d34881e11fdf7837232f3b4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 3e3ee6e406..66274e8115 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1320,12 +1320,17 @@ QByteArray QIODevice::readAll() newline will not be inserted into the buffer. On windows newline characters are replaced with '\\n'. + Note that on sequential devices, data may not be immediately available, + which may result in a partial line being returned. By calling the + canReadLine() function before reading, you can check whether a complete + line (including the newline character) can be read. + This function calls readLineData(), which is implemented using repeated calls to getChar(). You can provide a more efficient implementation by reimplementing readLineData() in your own subclass. - \sa getChar(), read(), write() + \sa getChar(), read(), canReadLine(), write() */ qint64 QIODevice::readLine(char *data, qint64 maxSize) { |