Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.4.2
-
None
-
-
1f22fc995 (dev), bfcfd2394 (6.5), 4672843ae (6.6)
Description
Using QFuture continuations with `unique_ptr` crashes, as in the following example
#include <memory> #include <QCoreApplication> #include <QFuture> #include <QPromise> #include <QSharedPointer> #include <QThread> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QSharedPointer<QPromise<std::unique_ptr<int>>> sharedPromise( new QPromise<std::unique_ptr<int>>); QFuture<std::unique_ptr<int>> future = sharedPromise->future(); QScopedPointer<QThread> thread(QThread::create( [](QSharedPointer<QPromise<std::unique_ptr<int>>> sharedPromise) { // doing some work QThread::sleep(1); sharedPromise->start(); sharedPromise->addResult(std::make_unique<int>(1)); sharedPromise->finish(); }, sharedPromise)); thread->start(); future.then([](const std::unique_ptr<int> &value) { qDebug() << *value; }); QThread::sleep(2); }
Simply replacing `unique_ptr` with `shared_ptr` fixes the problem.
Attachments
Issue Links
- relates to
-
QTBUG-119810 QFuture continuation with deleted context
- Closed