qt5base-lts/examples/qtconcurrent
Ivan Solovev 5ddb5d1fee Rework imagescaling example to avoid potential crashes
Creating a continuation with QtFuture::Launch::Async policy does not
work well with the example, because it still needs to update the UI
once the async continuation is finished. If the user decides to
close the application while the async continuation is executed,
the next continuation will be accessing data from the destroyed
Images object.

Fix it by using QtConcurrent::run() to do the "heavy" work in a
separate thread, and use a QFutureWatcher to handle the results of
the async execution. Update the example documentation accordingly.

After this patch the example still shows the usage of continuations
and onCanceled()/onFailed() handlers. However, it now does not
illustrate the usage of different launch policies and continuation
contexts. It might not be a big issue, because the QFuture
documentation describes these topics rather extensively.

Fixes: QTBUG-103514
Pick-to: 6.5
Change-Id: I8142535064ff7a4e8007a5c0a8fe7709d6d942ec
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-04-26 19:27:30 +02:00
..
imagescaling Rework imagescaling example to avoid potential crashes 2023-04-26 19:27:30 +02:00
primecounter Example: rename progressdialog to primecounter and modernize it 2023-03-21 11:19:42 +01:00
wordcount Example: update wordcount example 2023-03-20 20:58:08 +01:00
CMakeLists.txt Example: rename progressdialog to primecounter and modernize it 2023-03-21 11:19:42 +01:00
qtconcurrent.pro Example: rename progressdialog to primecounter and modernize it 2023-03-21 11:19:42 +01:00
README Remove references to demos from docs. 2011-07-05 19:57:54 +02:00

Qt 4 extends Qt's support for multithreaded applications with an API for
concurrent programming which includes implementations of the well-known
map-reduce and filter-reduce algorithms.


Documentation for these examples can be found via the Examples
link in the main Qt documentation.