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.

Pick-to: 6.9
Change-Id: I48d82d788d495bac43c6adb114dfdd95a8dd0d1f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
Marc Mutz 2025-01-06 15:14:36 +01:00
parent f7c3acd27f
commit 21811161c9

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);
}