
Avoiding random crashes when multithreading Qt - artoonie
https://medium.com/@armin.samii/avoiding-random-crashes-when-multithreading-qt-f740dc16059
======
billconan
the first example code is an expected issue, according to Qt's document, only
the main thread should update the gui:

GUI Thread and Worker Thread As mentioned, each program has one thread when it
is started. This thread is called the "main thread" (also known as the "GUI
thread" in Qt applications). The Qt GUI must run in this thread. All widgets
and several related classes, for example QPixmap, don't work in secondary
threads. A secondary thread is commonly referred to as a "worker thread"
because it is used to offload processing work from the main thread.

[http://doc.qt.io/qt-5/thread-basics.html](http://doc.qt.io/qt-5/thread-
basics.html)

~~~
artoonie
Point is (and I should clarify in the post): qt doesn't document which
functions do and don't update the GUI, and you have no guarantees when calling
an arbitrary Qt function that it won't. This is practical advice to stay safe.
A seemingly innocuous Qt function might internally update the GUI, as shown in
the example.

