diff --git a/src/corelib/platform/android/qandroidnativeinterface.cpp b/src/corelib/platform/android/qandroidnativeinterface.cpp index 886604d0ab..d54bc862dd 100644 --- a/src/corelib/platform/android/qandroidnativeinterface.cpp +++ b/src/corelib/platform/android/qandroidnativeinterface.cpp @@ -19,8 +19,12 @@ QT_BEGIN_NAMESPACE #if QT_CONFIG(future) && !defined(QT_NO_QOBJECT) static const char qtNativeClassName[] = "org/qtproject/qt/android/QtNative"; -typedef std::pair, QSharedPointer>> RunnablePair; -typedef std::deque PendingRunnables; +struct PendingRunnable { + std::function function; + QSharedPointer> promise; +}; + +using PendingRunnables = std::deque; Q_GLOBAL_STATIC(PendingRunnables, g_pendingRunnables); Q_CONSTINIT static QBasicMutex g_pendingRunnablesMutex; #endif @@ -191,7 +195,11 @@ QFuture QNativeInterface::QAndroidApplication::runOnAndroidMainThread( } QMutexLocker locker(&g_pendingRunnablesMutex); - g_pendingRunnables->push_back(std::pair(runnable, promise)); +#ifdef __cpp_aggregate_paren_init + g_pendingRunnables->emplace_back(runnable, std::move(promise)); +#else + g_pendingRunnables->push_back({runnable, std::move(promise)}); +#endif locker.unlock(); QJniObject::callStaticMethod(qtNativeClassName, @@ -209,15 +217,14 @@ static void runPendingCppRunnables(JNIEnv */*env*/, jobject /*obj*/) if (g_pendingRunnables->empty()) break; - std::pair pair = std::move(g_pendingRunnables->front()); + PendingRunnable r = std::move(g_pendingRunnables->front()); g_pendingRunnables->pop_front(); locker.unlock(); // run the runnable outside the sync block! - auto promise = pair.second; - if (!promise->isCanceled()) - promise->addResult(pair.first()); - promise->finish(); + if (!r.promise->isCanceled()) + r.promise->addResult(r.function()); + r.promise->finish(); } } #endif