Qt Graphical Objects & Multi-Thread
Qt graphical objects are not thread-safe.

This package contains two files (a header file and a source file), together with an optional Qt projet file (which can be generate with Qt's qmake). Executable can either be obtained using Qt Creator or both qmake and make (together with a compiler, e.g. gcc). Generating documentation requires either Qt Creator or Doxygen.

When compiled with BUGGY defined (e.g. using -DBUGGY option for gcc, in DEFINES variable of the qmake-generated Makefile - it is also needed when generating moc files), this simple example shows what happens if two different threads modify graphical objects: Qt has then an unexpected behaviour, leading to programm abortion with segmentation violation. This behaviour is hard to obtain, but is easily triggered with a high frequency in the second thread.

When compiled without BUGGY defined (default compilation), the second thread sends a signal, which is caught by the main thread (the one which started Qt main loop, which handles the graphical objects) and handled by launching the related update of the graphical object. I have not been able then to get previous unexpected behaviour (but Qt 4.8.7 has a problem with widget erasing, which has been corrected in Qt 5.5.1)...

Author
A. Scheuer (Alexi.nosp@m.s.Sc.nosp@m.heuer.nosp@m.@lor.nosp@m.ia.fr, members.loria.fr/Alexis.Scheuer).