diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-07-03 16:03:54 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-06 14:12:29 +0000 |
commit | d92c03656da7fb537900c74f8f37d6aba9d41639 (patch) | |
tree | 69aee5daf88b0fb40783b699a564a3f925e19e55 /src/corelib/io | |
parent | 4df6f2331d7453975ad192912eb33dde06113211 (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.
Change-Id: Ia2c1c438cc68d2672d34881e11fdf7837232f3b4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
(cherry picked from commit 03272e601ce0b03c36717dac0a60c2fdd8987bee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/io')
-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 f3354cad65..b776f6fddb 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) { |