summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-11-16 16:38:18 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2009-11-19 03:01:55 (GMT)
commit302152bca4dc690574e1b841b60a343dba47e86a (patch)
tree4979eba40cf5e5b64ff68b3e8363390a59ef6e6c /tests
parentf68fa03ab06440d26b8e667fa3b65375d3fa0c00 (diff)
downloadQt-302152bca4dc690574e1b841b60a343dba47e86a.zip
Qt-302152bca4dc690574e1b841b60a343dba47e86a.tar.gz
Qt-302152bca4dc690574e1b841b60a343dba47e86a.tar.bz2
Removing unnecessary chunking and stat'ing when reading QIODevice
Chunk size increased to QIODEVICE_BUFFERSIZE (currently 16k) where chunking is still needed. Namely, on sequential devices and when QByteArray is unable to allocate a large enough buffer. This is necessary for backward compatibility Improved validation and prevention of overflow in maxSize argument. Updated autotest that relied on a null QByteArray when no data was available and no errors were found. The only guarantee we should be providing in this case is an empty result -- even though that behavior is preserved for the time being. Affected functions: * QIODevice::read(qint64 maxSize) Chunking will still happen for large maxSize (i.e., QByteArray resize fails), where it could be used as a synonym for QIODevice::readAll(). No stat'ing performed. Read from device continues for as long as it is successful. Stops if an error occurs or if we get less data than requested. * QIODevice::readAll() Chunking is performed for sequential devices where total size wouldn't be known beforehand. For sequential devices, reading continues as long as data is returned, even if less than requested. Non-sequential devices will be stat'ed once. If QIODevice::size returns 0, this is taken to mean unknown size and chunking is performed. Otherwise, a single read request is made for the specified size. On failure to resize QByteArray, nothing is returned. * QIODevice::readLine(qint64 maxSize) Chunking is performed for maxSize == 0, or if we can't allocate a large enough buffer. No stat'ing performed at this level. Read from device continues until EOL is found, as long as we get all requested data. Task-number: QT-2347 Reviewed-by: Thiago Macieira Reviewed-by: Miikka Heikkinen (cherry picked from commit 1e6b424b692b20dcfec920f8d3563e520ec1ff05)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qfile/tst_qfile.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index b3d6fd9..880498e 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -2489,13 +2489,13 @@ void tst_QFile::readEof()
}
QByteArray ret = file.read(10);
- QVERIFY(ret.isNull());
+ QVERIFY(ret.isEmpty());
QVERIFY(file.error() == QFile::NoError);
QVERIFY(file.atEnd());
// Do it again to ensure that we get the same result
ret = file.read(10);
- QVERIFY(ret.isNull());
+ QVERIFY(ret.isEmpty());
QVERIFY(file.error() == QFile::NoError);
QVERIFY(file.atEnd());
}