qt5base-lts/examples
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
..
aggregate install a sane top-level examples.pro file 2012-12-11 13:37:57 +01:00
corelib Android-example: add missing properties in AndroidManifest.xml 2023-04-26 13:47:43 +00:00
dbus complexpingpong example: Modernize the code 2023-03-28 19:42:01 +02:00
embedded examples: port embedded examples to new connection style 2022-12-21 21:52:17 +01:00
gui Remove "Analog Clock Window Example" 2023-02-07 17:34:42 +00:00
network Torrent example: update usage of integer types 2023-04-11 18:25:42 +01:00
opengl Tune textures example to work with wasm and update docs 2023-04-25 18:10:44 +02:00
qmake examples: port qmake examples to new connection style 2022-12-21 22:52:17 +02:00
qpa Examples: Add missing include guards 2023-02-01 18:12:36 +00:00
qtconcurrent Rework imagescaling example to avoid potential crashes 2023-04-26 19:27:30 +02:00
qtestlib Examples: Use PRIVATE CMake linkage 2022-11-30 14:48:50 +01:00
sql examples: Connect Quit action to QCoreApplication::quit, not QWidget::close 2023-02-20 15:18:18 +01:00
vulkan Docs: don't link to removed example 2023-04-11 14:37:36 +02:00
widgets Doc: Use the \examplecategory macro to tag examples 2023-04-11 17:25:42 +00:00
xml Move streambookmarks example into corelibe/serialization 2023-03-31 13:26:42 +02:00
CMakeLists.txt Examples: Use Qt6:: to qualify Qt CMake packages 2022-11-17 19:59:11 +01:00
examples.pro Turn off the dbus examples for qmake-generated VS projects 2021-02-09 15:45:06 +01:00
README Remove more references to demos. 2011-07-08 15:36:26 +02:00

Qt is supplied with a number of example applications that have been
written to provide developers with examples of the Qt API in use,
highlight good programming practice, and showcase features found in each of
Qt's core technologies.


Documentation for examples can be found in the Examples section
of the Qt documentation.