aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2016-02-08 16:26:19 +0100
committerEike Ziller <eike.ziller@theqtcompany.com>2016-02-10 10:58:55 +0000
commit72af6b7834f69cf6380b6df407c70914a3e7550d (patch)
tree756858f17d8450b2ae7a8ebd29da38126cb85f05
parentece316fb648155414d2fddada32b7cb9445c49c7 (diff)
runAsync: Remove ResultType template parameter.
It is now deduced from either the type of the QFutureInterface<ResultType> function argument, or the return type. Change-Id: Iddab3cc329206c649a6e55a44b2de2d406701dee Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
-rw-r--r--src/libs/qmljs/qmljsmodelmanagerinterface.cpp22
-rw-r--r--src/libs/utils/runextensions.h187
-rw-r--r--src/libs/utils/shellcommand.cpp2
-rw-r--r--src/plugins/autotest/testcodeparser.cpp2
-rw-r--r--src/plugins/autotest/testrunner.cpp4
-rw-r--r--src/plugins/coreplugin/locator/locatorfiltertest.cpp5
-rw-r--r--src/plugins/coreplugin/locator/locatorwidget.cpp3
-rw-r--r--src/plugins/git/gitgrep.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/qmakenodes.cpp8
-rw-r--r--src/plugins/qmljseditor/qmljsfindreferences.cpp12
-rw-r--r--src/plugins/qmljseditor/qmljssemantichighlighter.cpp4
-rw-r--r--src/plugins/qmljseditor/qmltaskmanager.cpp2
-rw-r--r--src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp4
-rw-r--r--src/plugins/texteditor/generichighlighter/manager.cpp2
-rw-r--r--src/plugins/vcsbase/cleandialog.cpp4
-rw-r--r--tests/auto/runextensions/tst_runextensions.cpp176
16 files changed, 290 insertions, 149 deletions
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
index 37388baf03..de0ad9d61a 100644
--- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
+++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
@@ -319,10 +319,10 @@ QFuture<void> ModelManagerInterface::refreshSourceFiles(const QStringList &sourc
if (sourceFiles.isEmpty())
return QFuture<void>();
- QFuture<void> result = Utils::runAsync<void>(&ModelManagerInterface::parse,
- workingCopyInternal(), sourceFiles,
- this, Dialect(Dialect::Qml),
- emitDocumentOnDiskChanged);
+ QFuture<void> result = Utils::runAsync(&ModelManagerInterface::parse,
+ workingCopyInternal(), sourceFiles,
+ this, Dialect(Dialect::Qml),
+ emitDocumentOnDiskChanged);
cleanupFutures();
m_futures.append(result);
@@ -348,9 +348,9 @@ QFuture<void> ModelManagerInterface::refreshSourceFiles(const QStringList &sourc
void ModelManagerInterface::fileChangedOnDisk(const QString &path)
{
- Utils::runAsync<void>(&ModelManagerInterface::parse,
- workingCopyInternal(), QStringList() << path,
- this, Dialect(Dialect::AnyLanguage), true);
+ Utils::runAsync(&ModelManagerInterface::parse,
+ workingCopyInternal(), QStringList() << path,
+ this, Dialect(Dialect::AnyLanguage), true);
}
void ModelManagerInterface::removeFiles(const QStringList &files)
@@ -1096,9 +1096,9 @@ void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths)
}
if (pathToScan.length() > 1) {
- QFuture<void> result = Utils::runAsync<void>(&ModelManagerInterface::importScan,
- workingCopyInternal(), pathToScan,
- this, true, true);
+ QFuture<void> result = Utils::runAsync(&ModelManagerInterface::importScan,
+ workingCopyInternal(), pathToScan,
+ this, true, true);
cleanupFutures();
m_futures.append(result);
@@ -1243,7 +1243,7 @@ void ModelManagerInterface::startCppQmlTypeUpdate()
if (!cppModelManager)
return;
- m_cppQmlTypesUpdater = Utils::runAsync<void>(&ModelManagerInterface::updateCppQmlTypes,
+ m_cppQmlTypesUpdater = Utils::runAsync(&ModelManagerInterface::updateCppQmlTypes,
this, cppModelManager->snapshot(), m_queuedCppDocuments);
m_queuedCppDocuments.clear();
}
diff --git a/src/libs/utils/runextensions.h b/src/libs/utils/runextensions.h
index 7ce245e239..4b9c3b4073 100644
--- a/src/libs/utils/runextensions.h
+++ b/src/libs/utils/runextensions.h
@@ -435,6 +435,138 @@ QT_END_NAMESPACE
namespace Utils {
namespace Internal {
+/*
+ resultType<F>::type
+
+ Returns the type of results that would be reported by a callable of type F
+ when called through the runAsync methods. I.e. the ResultType in
+
+ void f(QFutureInterface<Result> &fi, ...)
+ ResultType f(...)
+
+ Returns void if F is not callable, and if F is a callable that does not take
+ a QFutureInterface& as its first parameter and returns void.
+*/
+
+template<typename T>
+struct hasCallOperator
+{
+ using yes = char;
+ using no = struct { char foo[2]; };
+
+ template<typename C>
+ static yes test(decltype(&C::operator()));
+
+ template<typename C>
+ static no test(...);
+
+ static const bool value = (sizeof(test<T>(0)) == sizeof(yes));
+};
+
+template <typename Function>
+struct resultType;
+
+template <typename Function, typename Arg>
+struct resultTypeWithArgument;
+
+template <typename Function, int index, bool>
+struct resultTypeTakesArguments;
+
+template <typename Function, bool>
+struct resultTypeIsMemberFunction;
+
+template <typename Function, bool>
+struct resultTypeIsFunctionLike;
+
+template <typename Function, bool>
+struct resultTypeHasCallOperator;
+
+template <typename Function, typename ResultType>
+struct resultTypeWithArgument<Function, QFutureInterface<ResultType>&>
+{
+ using type = ResultType;
+};
+
+template <typename Function, typename Arg>
+struct resultTypeWithArgument
+{
+ using type = typename functionTraits<Function>::ResultType;
+};
+
+template <typename Function, int index>
+struct resultTypeTakesArguments<Function, index, true>
+ : public resultTypeWithArgument<Function, typename functionTraits<Function>::template argument<index>::type>
+{
+};
+
+template <typename Function, int index>
+struct resultTypeTakesArguments<Function, index, false>
+{
+ using type = typename functionTraits<Function>::ResultType;
+};
+
+template <typename Function>
+struct resultTypeIsFunctionLike<Function, true>
+ : public resultTypeTakesArguments<Function, 0, (functionTraits<Function>::arity > 0)>
+{
+};
+
+template <typename Function>
+struct resultTypeIsMemberFunction<Function, true>
+ : public resultTypeTakesArguments<Function, 1, (functionTraits<Function>::arity > 1)>
+{
+};
+
+template <typename Function>
+struct resultTypeIsMemberFunction<Function, false>
+{
+ using type = void;
+};
+
+template <typename Function>
+struct resultTypeIsFunctionLike<Function, false>
+ : public resultTypeIsMemberFunction<Function, std::is_member_function_pointer<Function>::value>
+{
+};
+
+template <typename Function>
+struct resultTypeHasCallOperator<Function, false>
+ : public resultTypeIsFunctionLike<Function, std::is_function<typename std::remove_pointer<typename std::decay<Function>::type>::type>::value>
+{
+};
+
+template <typename Callable>
+struct resultTypeHasCallOperator<Callable, true>
+ : public resultTypeTakesArguments<decltype(&Callable::operator()), 1, (functionTraits<decltype(&Callable::operator())>::arity > 1)>
+{
+};
+
+template <typename Function>
+struct resultType
+ : public resultTypeHasCallOperator<Function, hasCallOperator<Function>::value>
+{
+};
+
+template <typename Function>
+struct resultType<Function&> : public resultType<Function>
+{
+};
+
+template <typename Function>
+struct resultType<const Function&> : public resultType<Function>
+{
+};
+
+template <typename Function>
+struct resultType<Function &&> : public resultType<Function>
+{
+};
+
+/*
+ Callable object that wraps a member function pointer with the object it
+ will be called on.
+*/
+
template <typename Function>
class MemberCallable;
@@ -478,6 +610,10 @@ private:
Obj *m_obj;
};
+/*
+ Helper functions for runAsync that run in the started thread.
+*/
+
// void function that does not take QFutureInterface
template <typename ResultType, typename Function, typename... Args>
void runAsyncReturnVoidDispatch(std::true_type, QFutureInterface<ResultType> futureInterface, Function &&function, Args&&... args)
@@ -557,6 +693,11 @@ void runAsyncImpl(QFutureInterface<ResultType> futureInterface, Function &&funct
std::forward<Args>(args)...);
}
+/*
+ AsyncJob is a QRunnable that wraps a function with the
+ arguments that are passed to it when it is run in a thread.
+*/
+
// can be replaced with std::(make_)index_sequence with C++14
template <std::size_t...>
struct indexSequence { };
@@ -671,9 +812,10 @@ private:
\sa QThreadPool
\sa QThread::Priority
*/
-template <typename ResultType, typename Function, typename... Args>
-QFuture<ResultType> runAsync(QThreadPool *pool, QThread::Priority priority,
- Function &&function, Args&&... args)
+template <typename Function, typename... Args,
+ typename ResultType = typename Internal::resultType<Function>::type>
+QFuture<ResultType>
+runAsync(QThreadPool *pool, QThread::Priority priority, Function &&function, Args&&... args)
{
auto job = new Internal::AsyncJob<ResultType,Function,Args...>
(std::forward<Function>(function), std::forward<Args>(args)...);
@@ -696,11 +838,13 @@ QFuture<ResultType> runAsync(QThreadPool *pool, QThread::Priority priority,
\sa runAsync(QThreadPool*,QThread::Priority,Function&&,Args&&...)
\sa QThread::Priority
*/
-template <typename ResultType, typename Function, typename... Args>
-QFuture<ResultType> runAsync(QThread::Priority priority, Function &&function, Args&&... args)
+template <typename Function, typename... Args,
+ typename ResultType = typename Internal::resultType<Function>::type>
+QFuture<ResultType>
+runAsync(QThread::Priority priority, Function &&function, Args&&... args)
{
- return runAsync<ResultType>(static_cast<QThreadPool *>(nullptr), priority,
- std::forward<Function>(function), std::forward<Args>(args)...);
+ return runAsync(static_cast<QThreadPool *>(nullptr), priority,
+ std::forward<Function>(function), std::forward<Args>(args)...);
}
/*!
@@ -708,16 +852,18 @@ QFuture<ResultType> runAsync(QThread::Priority priority, Function &&function, Ar
\sa runAsync(QThreadPool*,QThread::Priority,Function&&,Args&&...)
\sa QThread::Priority
*/
-template <typename ResultType, typename Function, typename... Args,
+template <typename Function, typename... Args,
typename = typename std::enable_if<
!std::is_same<typename std::decay<Function>::type, QThreadPool>::value
&& !std::is_same<typename std::decay<Function>::type, QThread::Priority>::value
- >::type>
-QFuture<ResultType> runAsync(Function &&function, Args&&... args)
-{
- return runAsync<ResultType>(static_cast<QThreadPool *>(nullptr),
- QThread::InheritPriority, std::forward<Function>(function),
- std::forward<Args>(args)...);
+ >::type,
+ typename ResultType = typename Internal::resultType<Function>::type>
+QFuture<ResultType>
+runAsync(Function &&function, Args&&... args)
+{
+ return runAsync(static_cast<QThreadPool *>(nullptr),
+ QThread::InheritPriority, std::forward<Function>(function),
+ std::forward<Args>(args)...);
}
/*!
@@ -725,15 +871,16 @@ QFuture<ResultType> runAsync(Function &&function, Args&&... args)
\sa runAsync(QThreadPool*,QThread::Priority,Function&&,Args&&...)
\sa QThread::Priority
*/
-template <typename ResultType, typename Function, typename... Args,
+template <typename Function, typename... Args,
typename = typename std::enable_if<
!std::is_same<typename std::decay<Function>::type, QThread::Priority>::value
- >::type>
-QFuture<ResultType> runAsync(QThreadPool *pool,
- Function &&function, Args&&... args)
+ >::type,
+ typename ResultType = typename Internal::resultType<Function>::type>
+QFuture<ResultType>
+runAsync(QThreadPool *pool, Function &&function, Args&&... args)
{
- return runAsync<ResultType>(pool, QThread::InheritPriority, std::forward<Function>(function),
- std::forward<Args>(args)...);
+ return runAsync(pool, QThread::InheritPriority, std::forward<Function>(function),
+ std::forward<Args>(args)...);
}
} // Utils
diff --git a/src/libs/utils/shellcommand.cpp b/src/libs/utils/shellcommand.cpp
index e0394cc4b0..15394d938e 100644
--- a/src/libs/utils/shellcommand.cpp
+++ b/src/libs/utils/shellcommand.cpp
@@ -222,7 +222,7 @@ void ShellCommand::execute()
if (d->m_jobs.empty())
return;
- QFuture<void> task = Utils::runAsync<void>(&ShellCommand::run, this);
+ QFuture<void> task = Utils::runAsync(&ShellCommand::run, this);
d->m_watcher.setFuture(task);
addTask(task);
}
diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp
index e8e379ed1f..1c39416919 100644
--- a/src/plugins/autotest/testcodeparser.cpp
+++ b/src/plugins/autotest/testcodeparser.cpp
@@ -738,7 +738,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
}
QFuture<TestParseResult> future
- = Utils::runAsync<TestParseResult>(&performParse, list, referencingFiles);
+ = Utils::runAsync(&performParse, list, referencingFiles);
m_futureWatcher.setFuture(future);
if (list.size() > 5) {
Core::ProgressManager::addTask(future, tr("Scanning for Tests"),
diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp
index daab98068b..2bece16b65 100644
--- a/src/plugins/autotest/testrunner.cpp
+++ b/src/plugins/autotest/testrunner.cpp
@@ -285,8 +285,8 @@ void TestRunner::runTests()
const QSharedPointer<TestSettings> settings = AutotestPlugin::instance()->settings();
const QString &metricsOption = TestSettings::metricsTypeToOption(settings->metrics);
- QFuture<TestResult *> future = Utils::runAsync<TestResult *>(&performTestRun, m_selectedTests,
- settings->timeout, metricsOption);
+ QFuture<TestResult *> future = Utils::runAsync(&performTestRun, m_selectedTests,
+ settings->timeout, metricsOption);
m_futureWatcher.setFuture(future);
Core::ProgressManager::addTask(future, tr("Running Tests"), Autotest::Constants::TASK_INDEX);
}
diff --git a/src/plugins/coreplugin/locator/locatorfiltertest.cpp b/src/plugins/coreplugin/locator/locatorfiltertest.cpp
index a2c1844f9e..a286e55e98 100644
--- a/src/plugins/coreplugin/locator/locatorfiltertest.cpp
+++ b/src/plugins/coreplugin/locator/locatorfiltertest.cpp
@@ -45,9 +45,8 @@ QList<LocatorFilterEntry> BasicLocatorFilterTest::matchesFor(const QString &sear
doBeforeLocatorRun();
const QList<ILocatorFilter *> filters = QList<ILocatorFilter *>() << m_filter;
m_filter->prepareSearch(searchText);
- QFuture<LocatorFilterEntry> locatorSearch = Utils::runAsync<LocatorFilterEntry>(&Internal::runSearch,
- filters,
- searchText);
+ QFuture<LocatorFilterEntry> locatorSearch = Utils::runAsync(&Internal::runSearch, filters,
+ searchText);
locatorSearch.waitForFinished();
doAfterLocatorRun();
return locatorSearch.results();
diff --git a/src/plugins/coreplugin/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp
index d5462459e5..4dd47d3bea 100644
--- a/src/plugins/coreplugin/locator/locatorwidget.cpp
+++ b/src/plugins/coreplugin/locator/locatorwidget.cpp
@@ -520,8 +520,7 @@ void LocatorWidget::updateCompletionList(const QString &text)
foreach (ILocatorFilter *filter, filters)
filter->prepareSearch(searchText);
- QFuture<LocatorFilterEntry> future = Utils::runAsync<LocatorFilterEntry>(&runSearch, filters,
- searchText);
+ QFuture<LocatorFilterEntry> future = Utils::runAsync(&runSearch, filters, searchText);
m_entriesWatcher->setFuture(future);
}
diff --git a/src/plugins/git/gitgrep.cpp b/src/plugins/git/gitgrep.cpp
index a00fa401b5..57ce4afb22 100644
--- a/src/plugins/git/gitgrep.cpp
+++ b/src/plugins/git/gitgrep.cpp
@@ -235,7 +235,7 @@ void GitGrep::writeSettings(QSettings *settings) const
QFuture<FileSearchResultList> GitGrep::executeSearch(
const TextEditor::FileFindParameters &parameters)
{
- return Utils::runAsync<FileSearchResultList>(GitGrepRunner::run, parameters);
+ return Utils::runAsync(GitGrepRunner::run, parameters);
}
} // Internal
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
index faed46c816..7c9e0dcb58 100644
--- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
@@ -1806,10 +1806,10 @@ void QmakeProFileNode::asyncUpdate()
m_readerExact->setExact(false);
m_parseFutureWatcher.waitForFinished();
EvalInput input = evalInput();
- QFuture<EvalResult *> future = Utils::runAsync<EvalResult *>(ProjectExplorerPlugin::sharedThreadPool(),
- QThread::LowestPriority,
- &QmakeProFileNode::asyncEvaluate,
- this, input);
+ QFuture<EvalResult *> future = Utils::runAsync(ProjectExplorerPlugin::sharedThreadPool(),
+ QThread::LowestPriority,
+ &QmakeProFileNode::asyncEvaluate,
+ this, input);
m_parseFutureWatcher.setFuture(future);
}
diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp
index a5c994265f..6c7ff6eb13 100644
--- a/src/plugins/qmljseditor/qmljsfindreferences.cpp
+++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp
@@ -891,10 +891,8 @@ void FindReferences::findUsages(const QString &fileName, quint32 offset)
{
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
- QFuture<Usage> result = Utils::runAsync<Usage>(
- &find_helper, modelManager->workingCopy(),
- modelManager->snapshot(), fileName, offset,
- QString());
+ QFuture<Usage> result = Utils::runAsync(&find_helper, modelManager->workingCopy(),
+ modelManager->snapshot(), fileName, offset, QString());
m_watcher.setFuture(result);
}
@@ -908,10 +906,8 @@ void FindReferences::renameUsages(const QString &fileName, quint32 offset,
if (newName.isNull())
newName = QLatin1String("");
- QFuture<Usage> result = Utils::runAsync<Usage>(
- &find_helper, modelManager->workingCopy(),
- modelManager->snapshot(), fileName, offset,
- newName);
+ QFuture<Usage> result = Utils::runAsync(&find_helper, modelManager->workingCopy(),
+ modelManager->snapshot(), fileName, offset, newName);
m_watcher.setFuture(result);
}
diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
index 493f2efeb2..0f2dea0442 100644
--- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
+++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
@@ -545,8 +545,8 @@ void SemanticHighlighter::rerun(const QmlJSTools::SemanticInfo &semanticInfo)
m_watcher.cancel();
m_startRevision = m_document->document()->revision();
- m_watcher.setFuture(Utils::runAsync<Use>(QThread::LowestPriority,
- &SemanticHighlighter::run, this, semanticInfo));
+ m_watcher.setFuture(Utils::runAsync(QThread::LowestPriority,
+ &SemanticHighlighter::run, this, semanticInfo));
}
void SemanticHighlighter::cancel()
diff --git a/src/plugins/qmljseditor/qmltaskmanager.cpp b/src/plugins/qmljseditor/qmltaskmanager.cpp
index 252dbf4391..f0e28ad6d3 100644
--- a/src/plugins/qmljseditor/qmltaskmanager.cpp
+++ b/src/plugins/qmljseditor/qmltaskmanager.cpp
@@ -152,7 +152,7 @@ void QmlTaskManager::updateMessagesNow(bool updateSemantic)
// process them
QFuture<FileErrorMessages> future =
- Utils::runAsync<FileErrorMessages>(
+ Utils::runAsync(
&collectMessages, modelManager->newestSnapshot(), modelManager->projectInfos(),
modelManager->defaultVContext(Dialect::AnyLanguage), updateSemantic);
m_messageCollector.setFuture(future);
diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
index 84ec468140..154e844804 100644
--- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
@@ -347,7 +347,7 @@ void QmlProfilerModelManager::save(const QString &filename)
connect(writer, &QObject::destroyed, this, &QmlProfilerModelManager::saveFinished,
Qt::QueuedConnection);
- QFuture<void> result = Utils::runAsync<void>([file, writer] (QFutureInterface<void> &future) {
+ QFuture<void> result = Utils::runAsync([file, writer] (QFutureInterface<void> &future) {
writer->setFuture(&future);
writer->save(file);
delete writer;
@@ -387,7 +387,7 @@ void QmlProfilerModelManager::load(const QString &filename)
acquiringDone();
}, Qt::QueuedConnection);
- QFuture<void> result = Utils::runAsync<void>([file, reader] (QFutureInterface<void> &future) {
+ QFuture<void> result = Utils::runAsync([file, reader] (QFutureInterface<void> &future) {
reader->setFuture(&future);
reader->load(file);
file->close();
diff --git a/src/plugins/texteditor/generichighlighter/manager.cpp b/src/plugins/texteditor/generichighlighter/manager.cpp
index 6286e2927a..2ab4e58e2b 100644
--- a/src/plugins/texteditor/generichighlighter/manager.cpp
+++ b/src/plugins/texteditor/generichighlighter/manager.cpp
@@ -322,7 +322,7 @@ void Manager::registerHighlightingFiles()
if (!m_registeringWatcher.isRunning()) {
clear();
- QFuture<RegisterData> future = Utils::runAsync<RegisterData>(ManagerProcessor());
+ QFuture<RegisterData> future = Utils::runAsync(ManagerProcessor());
m_registeringWatcher.setFuture(future);
} else {
m_hasQueuedRegistration = true;
diff --git a/src/plugins/vcsbase/cleandialog.cpp b/src/plugins/vcsbase/cleandialog.cpp
index af16ece7dd..7f424f0e6c 100644
--- a/src/plugins/vcsbase/cleandialog.cpp
+++ b/src/plugins/vcsbase/cleandialog.cpp
@@ -250,8 +250,8 @@ bool CleanDialog::promptToDelete()
return false;
// Remove in background
- QFuture<void> task = Utils::runAsync<void>(Internal::runCleanFiles, d->m_workingDirectory,
- selectedFiles, Internal::handleError);
+ QFuture<void> task = Utils::runAsync(Internal::runCleanFiles, d->m_workingDirectory,
+ selectedFiles, Internal::handleError);
const QString taskName = tr("Cleaning \"%1\"").
arg(QDir::toNativeSeparators(d->m_workingDirectory));
diff --git a/tests/auto/runextensions/tst_runextensions.cpp b/tests/auto/runextensions/tst_runextensions.cpp
index 13f8aabca1..eb3deff7fa 100644
--- a/tests/auto/runextensions/tst_runextensions.cpp
+++ b/tests/auto/runextensions/tst_runextensions.cpp
@@ -185,40 +185,40 @@ public:
void tst_RunExtensions::runAsync()
{
// free function pointer
- QCOMPARE(Utils::runAsync<int>(&report3).results(),
+ QCOMPARE(Utils::runAsync(&report3).results(),
QList<int>({0, 2, 1}));
- QCOMPARE(Utils::runAsync<int>(report3).results(),
+ QCOMPARE(Utils::runAsync(report3).results(),
QList<int>({0, 2, 1}));
- QCOMPARE(Utils::runAsync<double>(reportN, 4).results(),
+ QCOMPARE(Utils::runAsync(reportN, 4).results(),
QList<double>({0, 0, 0, 0}));
- QCOMPARE(Utils::runAsync<double>(reportN, 2).results(),
+ QCOMPARE(Utils::runAsync(reportN, 2).results(),
QList<double>({0, 0}));
QString s = QLatin1String("string");
const QString &crs = QLatin1String("cr string");
const QString cs = QLatin1String("c string");
- QCOMPARE(Utils::runAsync<QString>(reportString1, s).results(),
+ QCOMPARE(Utils::runAsync(reportString1, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(reportString1, crs).results(),
+ QCOMPARE(Utils::runAsync(reportString1, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(reportString1, cs).results(),
+ QCOMPARE(Utils::runAsync(reportString1, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(reportString1, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(reportString1, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
- QCOMPARE(Utils::runAsync<QString>(reportString2, s).results(),
+ QCOMPARE(Utils::runAsync(reportString2, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(reportString2, crs).results(),
+ QCOMPARE(Utils::runAsync(reportString2, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(reportString2, cs).results(),
+ QCOMPARE(Utils::runAsync(reportString2, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(reportString2, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(reportString2, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
// lambda
- QCOMPARE(Utils::runAsync<double>([](QFutureInterface<double> &fi, int n) {
+ QCOMPARE(Utils::runAsync([](QFutureInterface<double> &fi, int n) {
fi.reportResults(QVector<double>(n, 0));
}, 3).results(),
QList<double>({0, 0, 0}));
@@ -227,46 +227,46 @@ void tst_RunExtensions::runAsync()
const std::function<void(QFutureInterface<double>&,int)> fun = [](QFutureInterface<double> &fi, int n) {
fi.reportResults(QVector<double>(n, 0));
};
- QCOMPARE(Utils::runAsync<double>(fun, 2).results(),
+ QCOMPARE(Utils::runAsync(fun, 2).results(),
QList<double>({0, 0}));
// operator()
- QCOMPARE(Utils::runAsync<double>(Callable(), 3).results(),
+ QCOMPARE(Utils::runAsync(Callable(), 3).results(),
QList<double>({0, 0, 0}));
const Callable c{};
- QCOMPARE(Utils::runAsync<double>(c, 2).results(),
+ QCOMPARE(Utils::runAsync(c, 2).results(),
QList<double>({0, 0}));
// static member functions
- QCOMPARE(Utils::runAsync<double>(&MyObject::staticMember0).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::staticMember0).results(),
QList<double>({0, 2, 1}));
- QCOMPARE(Utils::runAsync<double>(&MyObject::staticMember1, 2).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::staticMember1, 2).results(),
QList<double>({0, 0}));
// member functions
const MyObject obj{};
- QCOMPARE(Utils::runAsync<double>(&MyObject::member0, &obj).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::member0, &obj).results(),
QList<double>({0, 2, 1}));
- QCOMPARE(Utils::runAsync<double>(&MyObject::member1, &obj, 4).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::member1, &obj, 4).results(),
QList<double>({0, 0, 0, 0}));
- QCOMPARE(Utils::runAsync<QString>(&MyObject::memberString1, &obj, s).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::memberString1, &obj, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(&MyObject::memberString1, &obj, crs).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::memberString1, &obj, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(&MyObject::memberString1, &obj, cs).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::memberString1, &obj, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(&MyObject::memberString1, &obj, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::memberString1, &obj, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
- QCOMPARE(Utils::runAsync<QString>(&MyObject::memberString2, &obj, s).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::memberString2, &obj, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(&MyObject::memberString2, &obj, crs).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::memberString2, &obj, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(&MyObject::memberString2, &obj, cs).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::memberString2, &obj, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(&MyObject::memberString2, &obj, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::memberString2, &obj, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
MyObject nonConstObj{};
- QCOMPARE(Utils::runAsync<double>(&MyObject::nonConstMember, &nonConstObj).results(),
+ QCOMPARE(Utils::runAsync(&MyObject::nonConstMember, &nonConstObj).results(),
QList<double>({0, 2, 1}));
}
@@ -274,40 +274,40 @@ void tst_RunExtensions::runInThreadPool()
{
QScopedPointer<QThreadPool> pool(new QThreadPool);
// free function pointer
- QCOMPARE(Utils::runAsync<int>(pool.data(), &report3).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &report3).results(),
QList<int>({0, 2, 1}));
- QCOMPARE(Utils::runAsync<int>(pool.data(), report3).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), report3).results(),
QList<int>({0, 2, 1}));
- QCOMPARE(Utils::runAsync<double>(pool.data(), reportN, 4).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), reportN, 4).results(),
QList<double>({0, 0, 0, 0}));
- QCOMPARE(Utils::runAsync<double>(pool.data(), reportN, 2).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), reportN, 2).results(),
QList<double>({0, 0}));
QString s = QLatin1String("string");
const QString &crs = QLatin1String("cr string");
const QString cs = QLatin1String("c string");
- QCOMPARE(Utils::runAsync<QString>(pool.data(), reportString1, s).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), reportString1, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), reportString1, crs).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), reportString1, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), reportString1, cs).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), reportString1, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), reportString1, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), reportString1, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), reportString2, s).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), reportString2, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), reportString2, crs).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), reportString2, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), reportString2, cs).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), reportString2, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), reportString2, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), reportString2, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
// lambda
- QCOMPARE(Utils::runAsync<double>(pool.data(), [](QFutureInterface<double> &fi, int n) {
+ QCOMPARE(Utils::runAsync(pool.data(), [](QFutureInterface<double> &fi, int n) {
fi.reportResults(QVector<double>(n, 0));
}, 3).results(),
QList<double>({0, 0, 0}));
@@ -316,43 +316,43 @@ void tst_RunExtensions::runInThreadPool()
const std::function<void(QFutureInterface<double>&,int)> fun = [](QFutureInterface<double> &fi, int n) {
fi.reportResults(QVector<double>(n, 0));
};
- QCOMPARE(Utils::runAsync<double>(pool.data(), fun, 2).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), fun, 2).results(),
QList<double>({0, 0}));
// operator()
- QCOMPARE(Utils::runAsync<double>(pool.data(), Callable(), 3).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), Callable(), 3).results(),
QList<double>({0, 0, 0}));
const Callable c{};
- QCOMPARE(Utils::runAsync<double>(pool.data(), c, 2).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), c, 2).results(),
QList<double>({0, 0}));
// static member functions
- QCOMPARE(Utils::runAsync<double>(pool.data(), &MyObject::staticMember0).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::staticMember0).results(),
QList<double>({0, 2, 1}));
- QCOMPARE(Utils::runAsync<double>(pool.data(), &MyObject::staticMember1, 2).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::staticMember1, 2).results(),
QList<double>({0, 0}));
// member functions
const MyObject obj{};
- QCOMPARE(Utils::runAsync<double>(pool.data(), &MyObject::member0, &obj).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::member0, &obj).results(),
QList<double>({0, 2, 1}));
- QCOMPARE(Utils::runAsync<double>(pool.data(), &MyObject::member1, &obj, 4).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::member1, &obj, 4).results(),
QList<double>({0, 0, 0, 0}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), &MyObject::memberString1, &obj, s).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::memberString1, &obj, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), &MyObject::memberString1, &obj, crs).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::memberString1, &obj, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), &MyObject::memberString1, &obj, cs).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::memberString1, &obj, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), &MyObject::memberString1, &obj, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::memberString1, &obj, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), &MyObject::memberString2, &obj, s).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::memberString2, &obj, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), &MyObject::memberString2, &obj, crs).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::memberString2, &obj, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), &MyObject::memberString2, &obj, cs).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::memberString2, &obj, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(pool.data(), &MyObject::memberString2, &obj, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), &MyObject::memberString2, &obj, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
}
@@ -379,7 +379,7 @@ public:
void tst_RunExtensions::moveOnlyType()
{
- QCOMPARE(Utils::runAsync<int>(MoveOnlyCallable(), MoveOnlyType()).results(),
+ QCOMPARE(Utils::runAsync(MoveOnlyCallable(), MoveOnlyType()).results(),
QList<int>({1}));
}
@@ -389,11 +389,11 @@ void tst_RunExtensions::threadPriority()
{
QScopedPointer<QThreadPool> pool(new QThreadPool);
// with pool
- QCOMPARE(Utils::runAsync<int>(pool.data(), QThread::LowestPriority, &report3).results(),
+ QCOMPARE(Utils::runAsync(pool.data(), QThread::LowestPriority, &report3).results(),
QList<int>({0, 2, 1}));
// without pool
- QCOMPARE(Utils::runAsync<int>(QThread::LowestPriority, report3).results(),
+ QCOMPARE(Utils::runAsync(QThread::LowestPriority, report3).results(),
QList<int>({0, 2, 1}));
}
@@ -401,37 +401,37 @@ void tst_RunExtensions::runAsyncNoFutureInterface()
{
// free function pointer
bool value = false;
- Utils::runAsync<void>(voidFunction, &value).waitForFinished();
+ Utils::runAsync(voidFunction, &value).waitForFinished();
QCOMPARE(value, true);
- QCOMPARE(Utils::runAsync<int>(one).results(),
+ QCOMPARE(Utils::runAsync(one).results(),
QList<int>({1}));
- QCOMPARE(Utils::runAsync<int>(identity, 5).results(),
+ QCOMPARE(Utils::runAsync(identity, 5).results(),
QList<int>({5}));
QString s = QLatin1String("string");
const QString &crs = QLatin1String("cr string");
const QString cs = QLatin1String("c string");
- QCOMPARE(Utils::runAsync<QString>(stringIdentity1, s).results(),
+ QCOMPARE(Utils::runAsync(stringIdentity1, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(stringIdentity1, crs).results(),
+ QCOMPARE(Utils::runAsync(stringIdentity1, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(stringIdentity1, cs).results(),
+ QCOMPARE(Utils::runAsync(stringIdentity1, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(stringIdentity1, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(stringIdentity1, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
- QCOMPARE(Utils::runAsync<QString>(stringIdentity2, s).results(),
+ QCOMPARE(Utils::runAsync(stringIdentity2, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(stringIdentity2, crs).results(),
+ QCOMPARE(Utils::runAsync(stringIdentity2, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(stringIdentity2, cs).results(),
+ QCOMPARE(Utils::runAsync(stringIdentity2, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(stringIdentity2, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(stringIdentity2, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
// lambda
- QCOMPARE(Utils::runAsync<double>([](int n) {
+ QCOMPARE(Utils::runAsync([](int n) -> double {
return n + 1;
}, 3).results(),
QList<double>({4}));
@@ -440,50 +440,50 @@ void tst_RunExtensions::runAsyncNoFutureInterface()
const std::function<double(int)> fun = [](int n) {
return n + 1;
};
- QCOMPARE(Utils::runAsync<double>(fun, 2).results(),
+ QCOMPARE(Utils::runAsync(fun, 2).results(),
QList<double>({3}));
// operator()
value = false;
- Utils::runAsync<void>(CallableWithoutQFutureInterface(), &value).waitForFinished();
+ Utils::runAsync(CallableWithoutQFutureInterface(), &value).waitForFinished();
QCOMPARE(value, true);
value = false;
const CallableWithoutQFutureInterface c{};
- Utils::runAsync<void>(c, &value).waitForFinished();
+ Utils::runAsync(c, &value).waitForFinished();
QCOMPARE(value, true);
// static member functions
value = false;
- Utils::runAsync<void>(&MyObjectWithoutQFutureInterface::staticMember0, &value).waitForFinished();
+ Utils::runAsync(&MyObjectWithoutQFutureInterface::staticMember0, &value).waitForFinished();
QCOMPARE(value, true);
- QCOMPARE(Utils::runAsync<double>(&MyObjectWithoutQFutureInterface::staticMember1, 2).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::staticMember1, 2).results(),
QList<double>({2}));
// member functions
const MyObjectWithoutQFutureInterface obj{};
value = false;
- Utils::runAsync<void>(&MyObjectWithoutQFutureInterface::member0, &obj, &value).waitForFinished();
+ Utils::runAsync(&MyObjectWithoutQFutureInterface::member0, &obj, &value).waitForFinished();
QCOMPARE(value, true);
- QCOMPARE(Utils::runAsync<double>(&MyObjectWithoutQFutureInterface::member1, &obj, 4).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::member1, &obj, 4).results(),
QList<double>({4}));
- QCOMPARE(Utils::runAsync<QString>(&MyObjectWithoutQFutureInterface::memberString1, &obj, s).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::memberString1, &obj, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(&MyObjectWithoutQFutureInterface::memberString1, &obj, crs).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::memberString1, &obj, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(&MyObjectWithoutQFutureInterface::memberString1, &obj, cs).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::memberString1, &obj, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(&MyObjectWithoutQFutureInterface::memberString1, &obj, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::memberString1, &obj, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
- QCOMPARE(Utils::runAsync<QString>(&MyObjectWithoutQFutureInterface::memberString2, &obj, s).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::memberString2, &obj, s).results(),
QList<QString>({s}));
- QCOMPARE(Utils::runAsync<QString>(&MyObjectWithoutQFutureInterface::memberString2, &obj, crs).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::memberString2, &obj, crs).results(),
QList<QString>({crs}));
- QCOMPARE(Utils::runAsync<QString>(&MyObjectWithoutQFutureInterface::memberString2, &obj, cs).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::memberString2, &obj, cs).results(),
QList<QString>({cs}));
- QCOMPARE(Utils::runAsync<QString>(&MyObjectWithoutQFutureInterface::memberString2, &obj, QString(QLatin1String("rvalue"))).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::memberString2, &obj, QString(QLatin1String("rvalue"))).results(),
QList<QString>({QString(QLatin1String("rvalue"))}));
MyObjectWithoutQFutureInterface nonConstObj{};
- QCOMPARE(Utils::runAsync<double>(&MyObjectWithoutQFutureInterface::nonConstMember, &nonConstObj, 4).results(),
+ QCOMPARE(Utils::runAsync(&MyObjectWithoutQFutureInterface::nonConstMember, &nonConstObj, 4).results(),
QList<double>({4}));
}