runOnAndroidMainThread(): Use QThreadPool::start() instead of QtConcurrent::run()

The latter is in a module (QtConcurrent) that depends on QtCore. Don't
make QtCore depend on QtConcurrent...

The code doesn't use the QFuture returned from QtConcurrent::run(),
anyway, so QThreadPool::start(function<void()>) is more than an
adequate replacement.

Task-number: QTBUG-109586
Change-Id: Id00a42525c3d7454a1fa2d4812de634dbbea1035
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 500e161987af24e2e10d46011d776258d5c0e47a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2022-12-22 11:58:17 +01:00 committed by Qt Cherry-pick Bot
parent a3d8512fe1
commit 991b5dfe8c

View File

@ -7,8 +7,10 @@
#include <QtCore/private/qjnihelpers_p.h>
#include <QtCore/qjniobject.h>
#if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
#include <QtConcurrent/QtConcurrent>
#include <QtCore/qfuture.h>
#include <QtCore/qfuturewatcher.h>
#include <QtCore/qpromise.h>
#include <QtCore/qthreadpool.h>
#include <deque>
#endif
@ -160,7 +162,7 @@ QFuture<QVariant> QNativeInterface::QAndroidApplication::runOnAndroidMainThread(
promise->start();
if (!timeout.isForever()) {
(void) QtConcurrent::run([=, &future]() {
QThreadPool::globalInstance()->start([=, &future]() {
QEventLoop loop;
QTimer::singleShot(timeout.remainingTime(), &loop, [&]() {
future.cancel();