QFuture: fix headercheck warning with Clang 17: member shadowing

Pretty sure this is a Clang bug because the promise member that it says
is getting shadowed shouldn't be in scope (`this` isn't being captured).

  qfuture_impl.h:538:60: error: declaration shadows a field of 'Continuation<Function, ResultType, ParentResultType>' [-Werror,-Wshadow]
  qfuture_impl.h:327:26: note: previous declaration is here

Change-Id: Ifeb6206a9fa04424964bfffd17883e21cfec6d8e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit bf7732baca43537b11ba8989d7e68fa9a9a6696d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 01bc132083487af32f091a4c6f56820aa9a91393)
This commit is contained in:
Thiago Macieira 2023-09-25 13:26:14 -07:00 committed by Volker Hilsheimer
parent 9e6de9e8ef
commit f674c47862

View File

@ -529,18 +529,18 @@ void Continuation<Function, ResultType, ParentResultType>::create(F &&func,
fi.setLaunchAsync(launchAsync); fi.setLaunchAsync(launchAsync);
auto continuation = [func = std::forward<F>(func), fi, promise = QPromise(fi), pool, auto continuation = [func = std::forward<F>(func), fi, promise_ = QPromise(fi), pool,
launchAsync](const QFutureInterfaceBase &parentData) mutable { launchAsync](const QFutureInterfaceBase &parentData) mutable {
const auto parent = QFutureInterface<ParentResultType>(parentData).future(); const auto parent = QFutureInterface<ParentResultType>(parentData).future();
Continuation<Function, ResultType, ParentResultType> *continuationJob = nullptr; Continuation<Function, ResultType, ParentResultType> *continuationJob = nullptr;
if (launchAsync) { if (launchAsync) {
auto asyncJob = new AsyncContinuation<Function, ResultType, ParentResultType>( auto asyncJob = new AsyncContinuation<Function, ResultType, ParentResultType>(
std::forward<Function>(func), parent, std::move(promise), pool); std::forward<Function>(func), parent, std::move(promise_), pool);
fi.setRunnable(asyncJob); fi.setRunnable(asyncJob);
continuationJob = asyncJob; continuationJob = asyncJob;
} else { } else {
continuationJob = new SyncContinuation<Function, ResultType, ParentResultType>( continuationJob = new SyncContinuation<Function, ResultType, ParentResultType>(
std::forward<Function>(func), parent, std::move(promise)); std::forward<Function>(func), parent, std::move(promise_));
} }
bool isLaunched = continuationJob->execute(); bool isLaunched = continuationJob->execute();
@ -567,11 +567,11 @@ void Continuation<Function, ResultType, ParentResultType>::create(F &&func,
fi.setLaunchAsync(true); fi.setLaunchAsync(true);
fi.setThreadPool(pool); fi.setThreadPool(pool);
auto continuation = [func = std::forward<F>(func), promise = QPromise(fi), auto continuation = [func = std::forward<F>(func), promise_ = QPromise(fi),
pool](const QFutureInterfaceBase &parentData) mutable { pool](const QFutureInterfaceBase &parentData) mutable {
const auto parent = QFutureInterface<ParentResultType>(parentData).future(); const auto parent = QFutureInterface<ParentResultType>(parentData).future();
auto continuationJob = new AsyncContinuation<Function, ResultType, ParentResultType>( auto continuationJob = new AsyncContinuation<Function, ResultType, ParentResultType>(
std::forward<Function>(func), parent, std::move(promise), pool); std::forward<Function>(func), parent, std::move(promise_), pool);
bool isLaunched = continuationJob->execute(); bool isLaunched = continuationJob->execute();
// If continuation is successfully launched, AsyncContinuation will be deleted // If continuation is successfully launched, AsyncContinuation will be deleted
// by the QThreadPool which has started it. // by the QThreadPool which has started it.
@ -671,11 +671,11 @@ void FailureHandler<Function, ResultType>::create(F &&function, QFuture<ResultTy
{ {
Q_ASSERT(future); Q_ASSERT(future);
auto failureContinuation = [function = std::forward<F>(function), promise = QPromise(fi)]( auto failureContinuation = [function = std::forward<F>(function), promise_ = QPromise(fi)](
const QFutureInterfaceBase &parentData) mutable { const QFutureInterfaceBase &parentData) mutable {
const auto parent = QFutureInterface<ResultType>(parentData).future(); const auto parent = QFutureInterface<ResultType>(parentData).future();
FailureHandler<Function, ResultType> failureHandler(std::forward<Function>(function), FailureHandler<Function, ResultType> failureHandler(std::forward<Function>(function),
parent, std::move(promise)); parent, std::move(promise_));
failureHandler.run(); failureHandler.run();
}; };