From c977e74afd18afff8729070f631e6b7a3f2887f5 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Wed, 26 Feb 2020 15:22:40 +0100 Subject: QtConcurrent::run: accept more then five function's arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][Potentially Source-Incompatible Changes] QtConcurrent::run has the following signatures: run(Function &&f, Args &&...args) and run(QThreadPool *pool, Function &&f, Args &&...args). If f is a member pointer, the first argument of args should be an object for which that member is defined (or a reference, or a pointer to it). See the documentation for more details. Fixes: QTBUG-82383 Change-Id: I18f7fcfb2adbdd9f75b29c346bd3516304e32d31 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Sona Kurazyan --- tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp | 14 +++++++------- tests/auto/corelib/io/qurl/tst_qurl.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/auto/corelib/io') diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index 4969e417f4..1d79d0dd1f 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -163,13 +163,13 @@ void tst_QLockFile::lockOutOtherThread() QVERIFY(lockFile.lock()); // Other thread can't acquire lock - QFuture ret = QtConcurrent::run(tryLockFromThread, fileName); + auto ret = QtConcurrent::run(tryLockFromThread, fileName); QCOMPARE(ret.result(), QLockFile::LockFailedError); lockFile.unlock(); // Now other thread can acquire lock - QFuture ret2 = QtConcurrent::run(tryLockFromThread, fileName); + auto ret2 = QtConcurrent::run(tryLockFromThread, fileName); QCOMPARE(ret2.result(), QLockFile::NoError); } @@ -186,13 +186,13 @@ static QLockFile::LockError lockFromThread(const QString &fileName) void tst_QLockFile::raceWithOtherThread() { const QString fileName = dir.path() + "/raceWithOtherThread"; - QFuture ret = QtConcurrent::run(lockFromThread, fileName); - QFuture ret2 = QtConcurrent::run(lockFromThread, fileName); + auto ret = QtConcurrent::run(lockFromThread, fileName); + auto ret2 = QtConcurrent::run(lockFromThread, fileName); QCOMPARE(ret.result(), QLockFile::NoError); QCOMPARE(ret2.result(), QLockFile::NoError); } -static bool lockFromThread(const QString &fileName, int sleepMs, QSemaphore *semThreadReady, QSemaphore *semMainThreadDone) +static bool lockFromThreadAndWait(const QString &fileName, int sleepMs, QSemaphore *semThreadReady, QSemaphore *semMainThreadDone) { QLockFile lockFile(fileName); if (!lockFile.lock()) { @@ -233,7 +233,7 @@ void tst_QLockFile::waitForLock() QLockFile lockFile(fileName); QSemaphore semThreadReady, semMainThreadDone; // Lock file from a thread - QFuture ret = QtConcurrent::run(lockFromThread, fileName, threadSleepMs, &semThreadReady, &semMainThreadDone); + auto ret = QtConcurrent::run(lockFromThreadAndWait, fileName, threadSleepMs, &semThreadReady, &semMainThreadDone); semThreadReady.acquire(); if (releaseEarly) // let the thread release the lock after threadSleepMs @@ -410,7 +410,7 @@ void tst_QLockFile::staleLockRace() QThreadPool::globalInstance()->setMaxThreadCount(10); QFutureSynchronizer synchronizer; for (int i = 0; i < 8; ++i) - synchronizer.addFuture(QtConcurrent::run(tryStaleLockFromThread, fileName)); + synchronizer.addFuture(QtConcurrent::run(tryStaleLockFromThread, fileName)); synchronizer.waitForFinished(); foreach (const QFuture &future, synchronizer.futures()) QVERIFY2(future.result().isEmpty(), qPrintable(future.result())); diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 8d046d5499..31d1de4234 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -4067,7 +4067,7 @@ void tst_QUrl::testThreading() QThreadPool::globalInstance()->setMaxThreadCount(100); QFutureSynchronizer sync; for (int i = 0; i < 100; ++i) - sync.addFuture(QtConcurrent::run(this, &tst_QUrl::testThreadingHelper)); + sync.addFuture(QtConcurrent::run(&tst_QUrl::testThreadingHelper, this)); sync.waitForFinished(); delete s_urlStorage; } -- cgit v1.2.3