Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.4.1
-
None
-
-
9e61cc4f7 (dev), a11a2ac13 (6.5), 5fed09633 (6.4), 34ac00a07 (tqtc/lts-6.2)
Description
Canceling a future that has a continuation attached that will be run in a different thread, causes a crash because some data in the continuation is not threre anymore.
saving the future of the continuation into a local variable fixes the issue.
this seemed to work fine with Qt 6.3
see this example.
#include <QCoreApplication> #include <QtConcurrent/QtConcurrent> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); auto future = QtConcurrent::run( []{}); // if the future of the continuation // is kept alive by storing into a // local variable, the cancel later works fine /*auto cont_future =*/ future.then(&a, [](){}); future.waitForFinished(); QEventLoop().processEvents(); future.cancel(); // crash here. return 0; }