Is signal-slot blocking.??
-
wrote on 8 Feb 2012, 06:16 last edited by
suppose i create an object of a class which has a slot. i connect this slot to any system signal like say readyRead() in constructor.
can the execution of signal-slot, block my calling function, where i created instance of the class.??
-
wrote on 8 Feb 2012, 07:15 last edited by
Not sure, are you asking if the constructor could block on processing a signal? I think this could happen if you have a multithreaded application (therefore signals are coming independently from the thread that is building the instance).
"This":http://developer.qt.nokia.com/doc/qt-4.8/threads-qobject.html could help. -
wrote on 8 Feb 2012, 08:41 last edited by
Can you please rephrase your question. It is completely incomprehensible (to me).
There is no way a slot connected in the constructor is execute before the constructor is finished, neither in single-threaded applications (the thread is executing your constructor) nor in multithreaded applications (the signal is dispatched as soon as the execution returns to the event loop, which happens in any case after the constructor has returned).
I see this only happening if you <code>qApp->processEvents()</code> or <code>moveToThread(this)</code> in your constructor - both highly questionable. Rule of thumb: just don't do it.
-
wrote on 8 Feb 2012, 08:48 last edited by
no, this will not block the execution of your program.
-
wrote on 8 Feb 2012, 10:59 last edited by
If the question is whether emitting a signal blocks the caller until the slots have been called, then the correct answer is "it depends".
In a single-threaded case, signal-slot connections are direct connections, meaning the slots get called when the signal is emitted (the signal function is called). The signal method returns after all connected slots have been called. In a multi-threaded case, it depends on whether the sender and receiver are associated with the same thread.
Have a look at http://doc.qt.nokia.com/4.7-snapshot/thread-basics.html for more details.
-
wrote on 10 Feb 2012, 12:07 last edited by
please explained your problem in detail.
-
wrote on 10 Feb 2012, 19:05 last edited by
miroslav is right, but I guess the more correct answer is: it depends on what connection flag you used when you connected the signal and the slot. The default flag will result in different behaviour in threaded and non-threaded cases.
1/7