qt5base-lts/tests/auto
Sona Kurazyan 9e61cc4f72 Fix crash when cancelling a QFuture that has continuation with context
To support cancellation of continuations attached via the parent future,
we store a pointer to continuation future's data in parent. This
requires preserving the lifetime of continuation future's data while the
parent is still alive (see 24dedaeaa1).
This is achieved by capturing the promise in the continuation's lambda,
which is only cleaned up after the parent's data is destroyed. This is
already the case for continuations without context, but was overlooked
for continuations with context: they transfer the ownership of the
continuation promise to lambda passed to QMetaObject::invokeMethod(),
which destroys the lambda's context after it's run. As a result, the
continuation's promise (and data, if there are no other copies of it)
is also destroyed, leaving the parent pointing to deleted continuation
data.

To fix this, capture a copy of continuation future's ref-counted data in
the continuation's lambda. This will guarantee that the continuation
data remains alive until the parent is destroyed and the continuation
is cleaned up.

Fixes: QTBUG-108790
Pick-to: 6.5 6.4 6.2
Change-Id: Ief4b37f31e652988d13b03499505ac65c7889226
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-06 14:00:56 +00:00
..
bic/data Revert "Add binary compatibility file generated against 6.4.0" 2022-11-17 13:52:02 +00:00
cmake Slow Deprecation of FILENAME_VARIABLE, replacement by OUTPUT_SCRIPT 2023-01-05 21:56:21 +01:00
concurrent Skip tst_qconcurrentrun completely if running under an emulator 2022-12-19 15:31:10 +00:00
corelib Fix crash when cancelling a QFuture that has continuation with context 2023-01-06 14:00:56 +00:00
dbus Adapt to QTimeZone replacing Qt::TimeSpec usage 2022-12-10 06:39:44 +01:00
gui Fix two compiler warnings 2023-01-05 21:01:22 +02:00
guiapplauncher Move QStateMachine from QtCore to QtScxml 2020-08-24 20:10:25 +02:00
network Fix two compiler warnings 2023-01-05 21:01:22 +02:00
opengl Remove the qmake project files 2021-01-07 15:32:28 +01:00
other Blacklist the QAccessibility::focusChild test on the wayland platform 2023-01-04 18:38:00 +01:00
printsupport Port from qAsConst() to std::as_const() 2022-10-11 23:17:18 +02:00
shared Don't hide object replacement char except in rich text 2022-12-14 19:19:01 +01:00
sql SQL: more documentation and test cleanups 2023-01-06 05:42:01 +00:00
testlib Adapt to QTimeZone replacing Qt::TimeSpec usage 2022-12-10 06:39:44 +01:00
tools RCCFileInfo: get lastModified file time in UTC directly 2023-01-05 14:46:38 +02:00
wasm Fix typo in QWasmWindowStack's name 2022-10-20 16:36:23 +02:00
widgets QListView: Prevent infinite loop when wrapping text of item with null-icon 2023-01-04 13:42:06 +01:00
xml QDomDocument: ensure a defined order of attributes when saving 2022-12-09 16:29:11 +01:00
CMakeLists.txt Add forwarding of CMake variables to ABI-specific external projects 2022-12-08 23:24:22 +01:00
network-settings.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00