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
For Gerrit Dashboard: QTBUG-112513 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
481557,2 | Fix a bug with qfuture continuations when using move only types | dev | qt/qtbase | Status: ABANDONED | 0 | 0 |
481561,14 | Fix segfault when using qfuture continuations with move only types | dev | qt/qtbase | Status: MERGED | +2 | 0 |
482103,4 | Fix segfault when using qfuture continuations with move only types | 6.5 | qt/qtbase | Status: MERGED | +2 | 0 |
482104,4 | Fix segfault when using qfuture continuations with move only types | 6.6 | qt/qtbase | Status: MERGED | +2 | 0 |