CopperSpice API  1.7.3
Thread Support

Threads and Implicitly Shared Classes

CopperSpice uses implicit sharing in some of its classes. Implicitly shared classes can safely be copied across threads. These classes are conditionally thread safe.

Proper locking must be used when sharing an instance of an implicitly shared class between threads. This is the same requirement placed on all conditionally thread safe classes.

Implicit sharing guarantees that a thread working on its own local instance of an implicitly shared class is safe. It is advisable to use signals and slots to pass data between threads as this can be done without the need for any explicit locking.

Painting in Threads

QPainter can be used in a thread to paint on a QImage, QPrinter, or QPicture. Painting on QPixmap and QWidget is not supported. On OS X the automatic progress dialog will not be displayed if you are printing from outside the GUI thread.

Any number of threads can paint at any given time. However only one thread can paint on a given paint device at one time.

On X11 systems without FontConfig support, CopperSpice can not render text outside of the GUI thread. You can use the QFontDatabase::supportsThreadedFontRendering() function to detect whether or not font rendering can be used outside the GUI thread.

Threads and Rich Text Processing

The QTextDocument, QTextCursor, and all related classes are conditionally thread safe.

A QTextDocument instance created in the GUI thread may contain QPixmap image resources. Use QTextDocument::clone() to create a copy of the document and pass the copy to another thread for further processing, such as printing.

Threads in SQL

A connection can only be used from within the thread where it was created. Moving connections between threads or creating queries from a different thread is not supported.

The third party libraries used by the QSqlDrivers can impose further restrictions on the SQL library in a multithreaded program. Consult the manual of your database client for more information.

Threads and CsSvg Library

The QSvgGenerator and QSvgRenderer classes in the CsSvg library are conditionally thread safe.