psih128
19th January 2010, 19:37
Suppose I have a background thread that at some point emits a signal from an object (the object belongs to the GUI thread!):
qDebug() << "before signal emitted";
emit mySignal();
qDebug() << "after signal emitted";
This signal is connected to a slot on another object from the GUI thread:
void QMyObject::mySlot() {
qDebug() << "signal received";
}
In the debug output I see the following order of messages:
before signal emitted
after signal emitted
signal received
Which makes me think that when the signal is emitted, it does not wait for the slots. Although the documentation states the opposite:
Execution of the code following the emit statement will occur once all slots have returned
Basically in my case I would want the emitting side to wait for all the slots to process the signal. The behavior I observe is probably due to cross-thread execution, but it should be uniform for all cases, shouldn't it?
Thanks
Anton
qDebug() << "before signal emitted";
emit mySignal();
qDebug() << "after signal emitted";
This signal is connected to a slot on another object from the GUI thread:
void QMyObject::mySlot() {
qDebug() << "signal received";
}
In the debug output I see the following order of messages:
before signal emitted
after signal emitted
signal received
Which makes me think that when the signal is emitted, it does not wait for the slots. Although the documentation states the opposite:
Execution of the code following the emit statement will occur once all slots have returned
Basically in my case I would want the emitting side to wait for all the slots to process the signal. The behavior I observe is probably due to cross-thread execution, but it should be uniform for all cases, shouldn't it?
Thanks
Anton