Call QPromise::start() early to avoid race condition

PR #22617.
This commit is contained in:
Vladimir Golovnev 2025-04-28 17:26:51 +03:00 committed by sledgehammer999
parent ad4bdc0653
commit c2f2a38582
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2
4 changed files with 6 additions and 7 deletions

View file

@ -3008,9 +3008,11 @@ QFuture<FileSearchResult> SessionImpl::findIncompleteFiles(const Path &savePath,
{
QPromise<FileSearchResult> promise;
QFuture<FileSearchResult> future = promise.future();
promise.start();
QMetaObject::invokeMethod(m_fileSearcher, [=, this, promise = std::move(promise)]() mutable
{
m_fileSearcher->search(filePaths, savePath, downloadPath, isAppendExtensionEnabled(), std::move(promise));
m_fileSearcher->search(filePaths, savePath, downloadPath, isAppendExtensionEnabled(), promise);
promise.finish();
});
return future;