i have thread (working great ) that invoking method in singletone object like this:
bool bInvokeUpdate= QMetaObject::invokeMethod(ApiManager::getInstance(),
"updateMainWindowTree",
Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, bReturnUpdate))
;
im using Qt::BlockingQueuedConnection so i can continue the thread work based on bool value .. any way
my question is dose this invocation remains in the thread ? or it cause to method to be preformed in the main thread ?
when i debug the app when im in the thread i see in the debugger that im in thread id xxxx
but when i set breakpoint in the updateMainWindowTree method , i see it jumping to the mainthread .
so what does it mean that i keep invoking functions from the main thread ? how can i avoid it?
Since you used
Qt::BlockingQueuedConnection, the call is executed in the thread to which theQObjectApiManager::getInstance()belongs.If that singleton belonged to the same thread as the calling code, you would have a deadlock.
You could use
Qt::DirectConnectionto stay in the same thread, but the name of your function suggests that it has to do with the GUI, so it should be executed in the main thread (meaning your current code and its behavior are probably already both correct).