Unsolved QTimer stop responding after some time
-
@CP71
I tried that, but it has same effect :/ -
@Svirac
I seem to see a 1ms of timeout, isn't It too frequent? -
@CP71
Yes it is, agree.Never the less I want to understand what is happening... I don't want to get surprised latter in the project, if same effect occurs with 5 ms timeouts.
Also question: what is happening if called slot doesn't manage to preform task (function) within e.g. 1 ms? I am assuming that QTimer timeouts are queued internally... is there some overflow?
Sorry for my language, I am not sure how to express myself properly :/Thanks for helping me out , I really appreciate it... I am really desperate at this point :)
-
@Svirac
Don't worry! My English is not good :(
I'm interested to understand me too, you never know for future ;) -
Also question: what is happening if called slot doesn't manage to preform task (function) within e.g. 1 ms? I am assuming that QTimer timeouts are queued internally... is there some overflow?
Depends whether your slot does or does not allow the event loop to run. Regardless I don't think they'll be queued.
-
@JonB
I am thinking to generate some slower "guard" timer in separate thread.To each thread fast timers I will add counter, locked with mutex. Guard timer will check counter and reset it each time. If counter is 0, it means that fast thread didn't accumulate it.... then guard timer will reset fast timer. Of course, over appropriate slot. My understanding is that its enough so simply start timer (it stops and reset).
Does it make sense?
-
@JonB
For a last 1.5 hours I am running application with 5ms and 20ms timeouts and everything works fine....
with 1ms and 2 ms one of timers stops responding (one always remains active).EDIT: just as I wrote this, after 1.5 hours one of faster timers (5ms) stop responding :(
-
@Svirac
I can say in our projects we have timers, some always active, some stopped in timeout slot and restart whet timeout slot is ended.
Our softwares run for a day or more, and so far we haven’t problems with QTimer.
Some problems with QElapsedTimer and sleep of thread, but not with QTimer, but happen in a particular condition and now we have learned to manage them, see https://forum.qt.io/topic/99973/qthread-msleep-doesn-t-work-when-system-time-is-changedWe have found a particular issue, but I didn't report because I want to check our code before to do this, we found that QTimer seems to stop run when a QMessageBox is shown, but is not always true this condition, so we must investigate why? Sometimes seems QMessageBox stops the even loop but I don’t know why, But at the moment for us is not a big problem and we can manage this condition.
-
-
@SGaist
thank you very much for your suggestion.
As soon as possible I’ll check and give you a confirm if I have used an open (in the hope I won’t forget to give you a confirm ;) ).
For the moment, thanks.
CP71 -
Hi @SGaist ,
better late than never ;).
Anyway sorry for late.
I don’t call exec to open my QmessageBox, I used a static method QMessageBox::warning( this , …) but I don’t know if it calls exec method.
This, in option, is QMainWindow where timer is run, timeout signals isn’t fired, or so it seems.
When QMessageBox is closed QTimer run again. -
@CP71
3 months later :)OK, your
QMessageBox::warning()
is an application-modal dialog and is behaving as though you had called theexec()
which @SGaist mentioned.And that is going to block the loop your timer runs under. You will need to rewrite your code to use the
QMessageBox::open()
call @SGaist referred you to.For discussion see e.g. https://stackoverflow.com/questions/14676085/qmessagebox-halts-qtimer .
If this is an issue for you --- you always want some timer event firing in the background, but you have many modal dialogs to show and don't want to rewrite callers --- you might have to rethink your usage of
QTimer
. -
@Svirac said in QTimer stop responding after some time:
I am working on Win7, qt 4.6.2.
...
Eventually I will drop from 1,2 ms to 5 and 10 ms loops
Have you checked if your slots are actually getting called at the millisecond intervals that you specified? If I remember correctly, Qt 4 did not support precise timers on Windows -- timers were only accurate to 16 ms.
Also, may I ask why you're using Qt 4.6? Try to upgrade to Qt 4.8.7 at least. But since this is sounds like a new project, I really really recommend Qt 5.12.4 (long-term support version) or Qt 5.13.0 (latest version)
-