summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfiledevice.cpp2
-rw-r--r--src/corelib/io/qiodevice.cpp16
-rw-r--r--src/corelib/io/qprocess.cpp2
-rw-r--r--src/network/socket/qabstractsocket.cpp7
-rw-r--r--src/network/socket/qlocalsocket_win.cpp3
5 files changed, 29 insertions, 1 deletions
diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp
index e1f1db9ead..fc1bc6009a 100644
--- a/src/corelib/io/qfiledevice.cpp
+++ b/src/corelib/io/qfiledevice.cpp
@@ -459,6 +459,8 @@ qint64 QFileDevice::readLineData(char *data, qint64 maxlen)
qint64 QFileDevice::readData(char *data, qint64 len)
{
Q_D(QFileDevice);
+ if (!len)
+ return 0;
unsetError();
if (!d->ensureFlushed())
return -1;
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 03bf59ed9d..a60aee1ebe 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -772,6 +772,8 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
printf("%p \tread 0x%hhx (%c) returning 1 (shortcut)\n", this,
int(c), isprint(c) ? c : '?');
#endif
+ if (d->buffer.isEmpty())
+ readData(data, 0);
return qint64(1);
}
}
@@ -786,8 +788,11 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
*d->pPos += lastReadChunkSize;
readSoFar += lastReadChunkSize;
// fast exit when satisfied by buffer
- if (lastReadChunkSize == maxSize && !(d->openMode & Text))
+ if (lastReadChunkSize == maxSize && !(d->openMode & Text)) {
+ if (d->buffer.isEmpty())
+ readData(data, 0);
return readSoFar;
+ }
data += lastReadChunkSize;
maxSize -= lastReadChunkSize;
@@ -906,6 +911,10 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
int(readSoFar), int(d->pos), d->buffer.size());
debugBinaryString(data - readSoFar, readSoFar);
#endif
+
+ if (d->buffer.isEmpty())
+ readData(data, 0);
+
return readSoFar;
}
@@ -1083,6 +1092,8 @@ qint64 QIODevice::readLine(char *data, qint64 maxSize)
qint64 readSoFar = 0;
if (!d->buffer.isEmpty()) {
readSoFar = d->buffer.readLine(data, maxSize);
+ if (d->buffer.isEmpty())
+ readData(data,0);
if (!sequential)
d->pos += readSoFar;
#if defined QIODEVICE_DEBUG
@@ -1622,6 +1633,9 @@ QString QIODevice::errorString() const
all the requested information was read and therefore does not retry reading
if there was a problem.
+ This function will be called with maxSize 0 when the device is
+ buffered and the buffer was emptied by a call to read().
+
\sa read(), readLine(), writeData()
*/
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index de8e3d4b49..7228ceca78 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1774,6 +1774,8 @@ void QProcess::setupChildProcess()
qint64 QProcess::readData(char *data, qint64 maxlen)
{
Q_D(QProcess);
+ if (!maxlen)
+ return 0;
QRingBuffer *readBuffer = (d->processChannel == QProcess::StandardError)
? &d->errorReadBuffer
: &d->outputReadBuffer;
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 3959419fed..8f290f6e2f 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -2324,6 +2324,13 @@ qint64 QAbstractSocket::readData(char *data, qint64 maxSize)
{
Q_D(QAbstractSocket);
+ // Check if the read notifier can be enabled again.
+ if (d->socketEngine && !d->socketEngine->isReadNotificationEnabled() && d->socketEngine->isValid())
+ d->socketEngine->setReadNotificationEnabled(true);
+
+ if (!maxSize)
+ return 0;
+
// This is for a buffered QTcpSocket
if (d->isBuffered && d->buffer.isEmpty())
// if we're still connected, return 0 indicating there may be more data in the future
diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp
index 35b0130afc..90c8fcec1e 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -200,6 +200,9 @@ qint64 QLocalSocket::readData(char *data, qint64 maxSize)
{
Q_D(QLocalSocket);
+ if (!maxSize)
+ return 0;
+
return d->pipeReader->read(data, maxSize);
}