QtFuture::result() deadlocks
-
In the image scaling example, adding a downloadFuture.result(); right after downloadFuture = download(urls); deadlocks, while adding a downloadFuture.takeResult(); triggers the isValid()'s assert, although after ignoring the assert it does return the expected value. result() works though from inside another future, just like in the Images::scaled() method. Is that a bug?
I've struggling for days with a similar scenario where I have a QtFuture::connect() waiting for a QNetworkReply::finished signal but this exhibits the same behavior. -
Hi,
Please provide a minimal compilable example that shows that behaviour.
Also which version of Qt are you using ?
-
@SGaist said in QtFuture::result() deadlocks:
Hi,
Please provide a minimal compilable example that shows that behaviour.
Also which version of Qt are you using ?
I tested it on 6.2.0-beta 1 and Windows 11 with the latest Visual C++ 2019 Preview compiler
As I said before, it was just the image scaling example that comes with Qt, adding a downloadFuture.result() or downloadFuture.takeResult() right after downloadFuture = download(urls);
Nevertheless, I have created a modified version here: https://github.com/ahmedyarub/imagescaling
The new line is added here https://github.com/ahmedyarub/imagescaling/blob/main/imagescaling.cpp#L115
You can test using both result() and takeResult() -
Here is a more concise example:
https://github.com/ahmedyarub/qfutura_deadlock -
Opened a bug ticket https://bugreports.qt.io/browse/QTBUG-95321
So far neither starting in a new thread nor using continuations solves the problem. I want to avoid using QFutureWatcher as it greatly complicates the code especially with the logic I'm trying to implement. -
I had very good help from the Qt staff, although I found the solution to be verbose but that would serve for the time being
https://bugreports.qt.io/browse/QTBUG-95321?focusedCommentId=576678&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-576678