mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 14:08:03 -06:00
committed by
sledgehammer999
parent
ad4bdc0653
commit
c2f2a38582
@@ -63,10 +63,8 @@ namespace
|
||||
}
|
||||
|
||||
void FileSearcher::search(const PathList &originalFileNames, const Path &savePath
|
||||
, const Path &downloadPath, const bool forceAppendExt, QPromise<FileSearchResult> promise)
|
||||
, const Path &downloadPath, const bool forceAppendExt, QPromise<FileSearchResult> &promise)
|
||||
{
|
||||
promise.start();
|
||||
|
||||
Path usedPath = savePath;
|
||||
PathList adjustedFileNames = originalFileNames;
|
||||
const bool found = findInDir(usedPath, adjustedFileNames, (forceAppendExt && downloadPath.isEmpty()));
|
||||
@@ -77,5 +75,4 @@ void FileSearcher::search(const PathList &originalFileNames, const Path &savePat
|
||||
}
|
||||
|
||||
promise.addResult(FileSearchResult {.savePath = usedPath, .fileNames = adjustedFileNames});
|
||||
promise.finish();
|
||||
}
|
||||
|
||||
@@ -49,5 +49,5 @@ public:
|
||||
using QObject::QObject;
|
||||
|
||||
void search(const PathList &originalFileNames, const Path &savePath
|
||||
, const Path &downloadPath, bool forceAppendExt, QPromise<FileSearchResult> promise);
|
||||
, const Path &downloadPath, bool forceAppendExt, QPromise<FileSearchResult> &promise);
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -3055,9 +3055,9 @@ QFuture<std::invoke_result_t<Func>> TorrentImpl::invokeAsync(Func &&func) const
|
||||
{
|
||||
QPromise<std::invoke_result_t<Func>> promise;
|
||||
const auto future = promise.future();
|
||||
promise.start();
|
||||
m_session->invokeAsync([func = std::forward<Func>(func), promise = std::move(promise)]() mutable
|
||||
{
|
||||
promise.start();
|
||||
promise.addResult(func());
|
||||
promise.finish();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user