CompactContinuation: make sure what is being deleted by runObj

A lambda creates a struct with a function-call operator. So use of
'this' in a lambda body is always a bit ambiguous (the outer object?
Or the lambda itself? even though C++ defines it unabiguously to the
former).

Use a named capture variable instead of 'this' to make it obvious what
is being deleted.

Amends 699162c6fa6121cc496338f1d8d6e1b4287f7760.

Change-Id: I48d82d788d495bac43c6adb114dfdd95a8dd0d1f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 21811161c9109c28da70b7bb9b28df33fa9b7766)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-01-06 15:14:36 +01:00 committed by Qt Cherry-pick Bot
parent 2a121a9506
commit 79bd27a82b

View File

@ -304,9 +304,9 @@ public:
: Storage{std::forward<F>(func)}, promise(std::move(p)), parentFuture(f),
threadPool(pool), type(Type::Async)
{
runObj = QRunnable::create([this] {
this->runFunction();
delete this;
runObj = QRunnable::create([continuation = this] {
continuation->runFunction();
delete continuation;
});
runObj->setAutoDelete(false);
}