PDA

View Full Version : timer->isActive bug



adamatic
18th March 2009, 10:52
Hello.

I am implementing a QTimer and my intention is to wait in a while loop until any of two conditins is true. One is refering to my aplication and is going to be all the time true, and the other condition is true until the timer have expired.

This is more or less the code which I am refering:




timer2= new QTimer(); // timer2 is a global QTimer
timer2->setSingleShot(true);
connect(timer2, SIGNAL(timeout()),this, SLOT(go()));
timer2->start(10000);

while( true && timer2->isActive()){

}






The problem is that the execution is all the time at the while loop and it is never conitnued, because although the time in running the timer2->isActive returns always true. And it is never gone to the SLOT go().

I have read that there is a qt bug related with this but it is resolved. I am using QT 4.4.4 on Windows Xp.

Cheers, and thank you in advance.

wysota
19th March 2009, 13:44
That's a very bad idea. You have to enter the event loop for the timer to timeout. Otherwise you can wait endlessly and the timer will remain active.
Read this article, especially the section about a local event loop.
http://doc.trolltech.com/qq/qq27-responsive-guis.html

It's not a bug by the way. Where did you here that?