Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
is QMetaObject::invokeMethod() thread-safe?
btse last edited by
Can anyone tell me if QMetaObject::invokeMethod() is thread-safe? I was looking at the documentation and noticed that Qt 5.12's documentation explicitly states it's thread-safe (https://doc.qt.io/qt-5.12/qmetaobject.html#invokeMethod) whereas Qt 5.11 and before does not explicitly state this (https://doc.qt.io/qt-5.11/qmetaobject.html#invokeMethod).
Based on the language used in the documentation, and the fact that it supports things like the Queued Connection and BlockingQueuedConnection, I'm assuming it is thread-safe even prior to 5.12? And perhaps them adding the Note was an oversight in previous version's documentation?
Here is the bug report that prompted the documentation update https://bugreports.qt.io/browse/QTBUG-72599 and root discussion that has led to it https://forum.qt.io/topic/97683/thread-safety-of-qmetaobject-invokemethod-e-g-slot-invoking-from-random-threads.
And perhaps them adding the Note was an oversight in previous version's documentation?
Exactly. Code is the same in earlier Qt versions.