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
Pick-to: 6.5 6.4 6.2
Change-Id: Id00a42525c3d7454a1fa2d4812de634dbbea1035
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Marc Mutz 2022-12-22 11:58:17 +01:00
parent c049601348
commit 500e161987

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();