Pass QDeadlineTimer by value in runOnAndroidMainThread()

Also change the timer default value to use QDeadlineTimer::Forever.

Pick-to: 6.2
Change-Id: Ia6d0101872a5d01b04e146cd9b2f90315cb8eb2e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Assam Boudjelthia 2021-07-29 11:58:04 +03:00
parent 6f682d4876
commit 50f53b9022
2 changed files with 3 additions and 5 deletions

View File

@ -69,14 +69,12 @@ struct Q_CORE_EXPORT QAndroidApplication
#if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
static QFuture<QVariant> runOnAndroidMainThread(const std::function<QVariant()> &runnable,
const QDeadlineTimer
&timeout = QDeadlineTimer(-1));
const QDeadlineTimer timeout = QDeadlineTimer::Forever);
template <class T>
std::enable_if_t<std::is_invocable_v<T> && std::is_same_v<std::invoke_result_t<T>, void>,
QFuture<void>> static runOnAndroidMainThread(const T &runnable,
const QDeadlineTimer
&timeout = QDeadlineTimer(-1))
const QDeadlineTimer timeout = QDeadlineTimer::Forever)
{
std::function<QVariant()> func = [runnable](){ runnable(); return QVariant(); };
return static_cast<QFuture<void>>(runOnAndroidMainThread(func, timeout));

View File

@ -188,7 +188,7 @@ void QNativeInterface::QAndroidApplication::hideSplashScreen(int duration)
#if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
QFuture<QVariant> QNativeInterface::QAndroidApplication::runOnAndroidMainThread(
const std::function<QVariant()> &runnable,
const QDeadlineTimer &timeout)
const QDeadlineTimer timeout)
{
QSharedPointer<QPromise<QVariant>> promise(new QPromise<QVariant>());
QFuture<QVariant> future = promise->future();