The Qt documentation states this about thread-safety and reentrancy:
Note: Qt classes are only documented as thread-safe if they are intended to be used by multiple threads. If a function is not marked as thread-safe or reentrant, it should not be used from different threads. If a class is not marked as thread-safe or reentrant then a specific instance of that class should not be accessed from different threads.
This seems to state that every function and class in Qt should be considered non-reentrant and non-thread-safe unless explicitly stated so.
However, in the documentation of QRect
and QPoint
, for example, neither thread-safety nor reentrancy is mentioned, but I find it hard to believe they are not. In fact, this old discussion says its a "lack" in the documentation:
These classes are just plain data (a few primitives), no shared structured or static data, so they are reentrant. That they are not marked as such, is a lack in our documentation.
So, how should we know if a function is reentrant or not? Is the reentrancy note omitted only for simple classes where it's implied by its obviousness?
I think the only safe answer to this question is to look at the source code. Clearly the Qt docs are not sufficient. Bugs should be filed with Qt for each undocumented reentrant class.
By Qt's definition of reentrancy, there are two criteria for determining if a Qt class is reentrant:
Accessing a singleton class would violate 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With