FilePath: Remove overloads for async tasks that don't take context

Passing mandatory context object clearly suggests a special
care should be taken for assuring the passed function
may still run when the task finishes in the future.

Fix FileStreamManager so that it deletes the streamer
even when context object was deleted in meantime.

Fix 2 usages of asyncCopy so that we pass a context object now.

Side note: passing nullptr as a context object is still
possible and should work, but it's not recommended.

Change-Id: I464438db42ed9292c2f89ecb9d5dde7c78f77640
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-03-17 11:17:51 +01:00
parent 13bf47c875
commit 81bd8e3bd8
5 changed files with 9 additions and 24 deletions

View File

@@ -637,32 +637,17 @@ FilePathInfo FilePath::filePathInfo() const
return fileAccess()->filePathInfo(*this);
}
FileStreamHandle FilePath::asyncCopy(const FilePath &target, const CopyContinuation &cont) const
{
return FileStreamerManager::copy(*this, target, cont);
}
FileStreamHandle FilePath::asyncCopy(const FilePath &target, QObject *context,
const CopyContinuation &cont) const
{
return FileStreamerManager::copy(*this, target, context, cont);
}
FileStreamHandle FilePath::asyncRead(const ReadContinuation &cont) const
{
return FileStreamerManager::read(*this, cont);
}
FileStreamHandle FilePath::asyncRead(QObject *context, const ReadContinuation &cont) const
{
return FileStreamerManager::read(*this, context, cont);
}
FileStreamHandle FilePath::asyncWrite(const QByteArray &data, const WriteContinuation &cont) const
{
return FileStreamerManager::write(*this, data, cont);
}
FileStreamHandle FilePath::asyncWrite(const QByteArray &data, QObject *context,
const WriteContinuation &cont) const
{