Q_INVOKABLE vs SIGNAL/SLOT thread safety
I have several methods which are defined as Q_INVOKABLE. One such method is:
Q_INVOKABLE void logError(const QString& msg_in);
This method is called by my QML objects to log error events as suggested above.
The class which defines this method is MainApp. It is running on my QGuiApplication event loop. MainApp also makes calls logError() to log its own error messages. I am trying to determine if the QML calls and my MainApp calls are thread safe, even though I am not explicitly defining a signal/slot connection
If you call a
Q_INVOKABLEmethod from QML it is called using QMetaObject::invokeMethod behind the scenes. So, it is thread-safe per se. But: Your usual QtQuick stuff lives on the GUI thread and thus, unless you explicitly use other threads, there's no problem anyways.
Edit: My original answer was wrong.
How are you calling that method ?
@SGaist from my QML, I am calling:
Where main_app is the instance of my application.
From the C++ side of the application, I am calling:
What @Wieland wrote is correct :)