05-01-2013 12:41 AM
I posted recently about a QTimer start(0) bug, so I changed my code to instead start the timer with a short interval of 100 milliseconds. Usually this works fine, but there are times when the timer doesn't fire until 10 seconds go by! Looking at the log file shows that there doesn't seem to be any other activity going on during this time. Is there a known issue here?
GuiTaskQueue::GuiTaskQueue() : super(NULL)
connect(&s_timer, SIGNAL(timeout()), this, SLOT(onTimer()));
when I start the timer:
s_timer.start(100); // milliseconds
the timer is not stopped (it's one-shot)
Solved! Go to Solution.
05-01-2013 09:45 AM
05-01-2013 10:57 AM
We have logging around the methods that can be called from UI events, timers, etc. (as well as almost all of the lower level calls made by these methods) and during this period nothing is logged so I am reasnably confident that there is nothing going on during this period that should cause the timer not to fire.
05-06-2013 10:17 AM
Here's what it looks like after investigating this for a while... when the timer is started from a non-GUI thread it won't fire until something happens on the GUI thread. Whether it is another timer that fires or whether it's the user taking some action, it seems that the timer that is started on the non-GUI thread needs some UI thread activtity before it will fire. This looks like a serious OS bug.
05-07-2013 07:44 PM
05-07-2013 07:51 PM
I have the GUI thread and a few other "background" threads. I create the timer on the GUI thread when the application starts. During the program execution the background threads periodically start the timer with a value of X. I expect the timer to fire in X milliseconds (approximately) from when the background thread called "start". I find that the timer is not actually fired until X milliseconds has passed AND THEN something has occured on the GUI thread such as the user took some action, or some other timer fired. If nothing is happening on the GUI thread (i.e. the application is idle) then the timer will not fire - until something ends up happening on the GUI thread. I have other timers going off so these seem to trigger the subject timer, as does user activity.
05-07-2013 07:58 PM
In many cases the thread that is calling "start" on the timer will soon thereafter call Wait() on a Semaphore. I haven't looked at whether this problem only occurs in these cases but it is an interesting possibility.
05-07-2013 08:01 PM
05-07-2013 08:04 PM
The heavy processing is currently being done by the background thread and then the GUI thread is only dealing with the result via the timer so I think I already meet your suggestion, unless I misunderstood.