summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qrandomaccessasyncfile.cpp
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2025-09-09 15:30:20 +0200
committerIvan Solovev <ivan.solovev@qt.io>2025-09-18 21:07:38 +0200
commit0f41ca136b50b3180ea3176a16cc7644029ce377 (patch)
tree190c2d297884a18ecc29070056b8e5715565e249 /src/corelib/io/qrandomaccessasyncfile.cpp
parent7d7eec6697b1611d1ed745f6b039e1e63a06b799 (diff)
Make QRandomAccessAsyncFile::open() an async operation
The tricky case now would be to handle the case when the user tries to call open() several times. Make sure that after the first operation is started, all the subsequent attempts to open will fail until the first operation is finished. Obviously, if the first open() was successful, the file needs to be closed before it can be re-opened. Add unit-tests to cover these cases. Also add some tests for close() corner cases. These tests are useful for this commit, as the logic of opening the file got more complicated. Task-number: QTBUG-136763 Change-Id: Id505e6278fbc1d523a52b54e69ba896a3d754762 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/io/qrandomaccessasyncfile.cpp')
-rw-r--r--src/corelib/io/qrandomaccessasyncfile.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/corelib/io/qrandomaccessasyncfile.cpp b/src/corelib/io/qrandomaccessasyncfile.cpp
index 0a2eece76ff..c544585de9d 100644
--- a/src/corelib/io/qrandomaccessasyncfile.cpp
+++ b/src/corelib/io/qrandomaccessasyncfile.cpp
@@ -18,12 +18,6 @@ QRandomAccessAsyncFile::~QRandomAccessAsyncFile()
close();
}
-bool QRandomAccessAsyncFile::open(const QString &filePath, QIODeviceBase::OpenMode mode)
-{
- Q_D(QRandomAccessAsyncFile);
- return d->open(filePath, mode);
-}
-
void QRandomAccessAsyncFile::close()
{
Q_D(QRandomAccessAsyncFile);
@@ -39,6 +33,19 @@ qint64 QRandomAccessAsyncFile::size() const
/*!
\internal
+ Attempts to open the file \a filePath with mode \a mode.
+
+ \include qrandomaccessasyncfile.cpp returns-qiooperation
+*/
+QIOOperation *QRandomAccessAsyncFile::open(const QString &filePath, QIODeviceBase::OpenMode mode)
+{
+ Q_D(QRandomAccessAsyncFile);
+ return d->open(filePath, mode);
+}
+
+/*!
+ \internal
+
Flushes any buffered data to the file.
\include qrandomaccessasyncfile.cpp returns-qiooperation