summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qrandomaccessasyncfile.cpp
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2025-09-02 16:33:01 +0200
committerIvan Solovev <ivan.solovev@qt.io>2025-09-18 21:07:38 +0200
commit7d7eec6697b1611d1ed745f6b039e1e63a06b799 (patch)
tree6b80a390894680a61e2db1c371180ff42870e1a3 /src/corelib/io/qrandomaccessasyncfile.cpp
parentb9bb896755d2c48c05765d8b558d2ea5471da32b (diff)
Extend tests for QRandomAccessAsyncFile
Add tests that check read/write operations with empty buffers. For owning read also test a case when a negative maxSize is provided. The latter revealed that the code was not handling negative maxSize properly. So, add a warning and reset it to zero in such case. The value of zero does not have any special meaning, and would simply result into the operation emitting finished() immediately. Task-number: QTBUG-136763 Change-Id: I72232a788ce2a18188f76d50db00b09b1af57169 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/io/qrandomaccessasyncfile.cpp')
-rw-r--r--src/corelib/io/qrandomaccessasyncfile.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/io/qrandomaccessasyncfile.cpp b/src/corelib/io/qrandomaccessasyncfile.cpp
index a971fdfd63b..0a2eece76ff 100644
--- a/src/corelib/io/qrandomaccessasyncfile.cpp
+++ b/src/corelib/io/qrandomaccessasyncfile.cpp
@@ -65,6 +65,11 @@ QIOOperation *QRandomAccessAsyncFile::flush()
QIOReadOperation *QRandomAccessAsyncFile::read(qint64 offset, qint64 maxSize)
{
Q_D(QRandomAccessAsyncFile);
+ if (maxSize < 0) {
+ qWarning("Using a negative maxSize in QRandomAccessAsyncFile::read() is incorrect. "
+ "Resetting to zero!");
+ maxSize = 0;
+ }
return d->read(offset, maxSize);
}