PDA

View Full Version : QTimer::singleShot stop at 12:00AM on second day



croliver
22nd August 2016, 16:16
I am using QT5 in visual studio.

I have the function below where I call singleShot for a some ms value according to the GUI (in this case 1000 ms). After single shot has passed it should call reset_TEER() and then rest some values and recall TEER(). This keeps the GUI responsive in-between measurements.

This works great, except that sometimes at 12:00 AM (midnight) singleshot never times out and the reset_TEER() is never called again. The last time I tried this it ran from 10:39AM 8/20 to 12:00AM 8/22. So, I expect Sunday is the problem, but I can't tell if Sunday is the only day that causes the problem because I have seen this happen once before (at the same midnight time). Other times it works for four days no problem.



void CLASS::reset_TEER(){
//do stuff
TEER();
}

void CLASS::TEER(){
for(){ //generic for loop here
}
TEER_count++;
if (TEER_count < ui.num_cycles->value() && ui.enable_repeat->isChecked())
QTimer::singleShot(ui.wait_num_cycles->value(), this, SLOT(reset_TEER()));
}

I can't find any information about why singleShot would do this. I do see that QTime will return to zero after 24 hours but they don't seem related. Should I be doing this a different way?

Thanks for your input.

Lesiok
22nd August 2016, 18:37
But this singleShot is conditional. Add something after line 11 :
else
qDebug() << "TEER count = " << TEER_count << " num_cyles->value() = " << ui.num_cyles->value() << " enable_repeat->isChecked = " << enable_repeat->isChecked();