PDA

View Full Version : lost signals ?



deepinlife
17th June 2008, 10:34
guys i have a scenario in which i send signal every certain amount of time delay.


QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(drawDemo()));
timer->start(30);


i receive this signal on a slot which do a hards drawing.sometimes when the slot takes very long time more than the period of the signal delay time



void drawDemo()
{
//heavy drawing
}


my question is what happens when the time comes of the signal ??
i mean does the qt sense the signal ? o it will be busy finish the slot?
and wait will happen if it will handle the signal while the slot is doing ?
do the qt has a queue for lost signals ? or it just discard ?or what happens exactly in that scenario ?

marcel
17th June 2008, 10:44
Since everything happens in the same thread the timer won't fire while drawDemo. If drawDemo takes 300ms then the timer will fire 10 times(one after another) after drawDemo ends.
The solution is to disable the timer when drawDemo enters and enable it back when it exists (disable it at the beginning and enable it at the end).

deepinlife
17th June 2008, 11:08
so it queued the signals..or that just happens with the timer signal ?

marcel
17th June 2008, 11:11
timers or threads posting events in another thread.