Don't create a QRunnable in QAndroidApplication::runOnAndroidMainThread() w/o timeout
Creating a QRunnable is expensive business, incl. setting up QThreadPool::globalInstance() if it wasn't set up already, so don't do it for a no-op task. Somewhat mitigates, but doesn't fix, QTBUG-109586. Task-number: QTBUG-109586 Pick-to: 6.5 6.4 6.2 Change-Id: If2043134414d68adc9188e5bb7650ca08046b4aa Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>bb10
parent
ad32854409
commit
26ea6157e6
|
|
@ -159,8 +159,8 @@ QFuture<QVariant> QNativeInterface::QAndroidApplication::runOnAndroidMainThread(
|
|||
QFuture<QVariant> future = promise->future();
|
||||
promise->start();
|
||||
|
||||
(void) QtConcurrent::run([=, &future]() {
|
||||
if (!timeout.isForever()) {
|
||||
if (!timeout.isForever()) {
|
||||
(void) QtConcurrent::run([=, &future]() {
|
||||
QEventLoop loop;
|
||||
QTimer::singleShot(timeout.remainingTime(), &loop, [&]() {
|
||||
future.cancel();
|
||||
|
|
@ -177,8 +177,8 @@ QFuture<QVariant> QNativeInterface::QAndroidApplication::runOnAndroidMainThread(
|
|||
});
|
||||
watcher.setFuture(future);
|
||||
loop.exec();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
QMutexLocker locker(&g_pendingRunnablesMutex);
|
||||
g_pendingRunnables->push_back(std::pair(runnable, promise));
|
||||
|
|
|
|||
Loading…
Reference in New Issue