Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-23150

elapsedtimer behaves erratic under windows

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: 4.8.x
    • Fix Version/s: 4.8.0
    • Component/s: Core: Event loop
    • Labels:
      None
    • Environment:
      windows (all versions)
    • Commits:
      f30a91ba9d98de1a0ebee5608ba289ac35871a8c

      Description

      We use the elapsed method from QElapsedTimer to replay files at the correct pace.
      We have now compiled Qt4.8.0 and are testing our code with it. (it worked nicely under 4.7.x)
      Now we noticed that the elapsed() method goes haywire after a few seconds, instead of nicely increasing we see the value behave rather heretic.

      Our investigation suggests that the code in "ticksToNanoseconds(qint64 ticks)" in QtSources/4.8.0/src/corelib/tools/qelapsedtimer_win.cpp is the problem.

      Our counterFrequency is set to 2.99 GHz but this way the elapsed() method will first try to convert the elapsed time into nanoseconds and divide aftwerwards by 1000000, so the qint64 returned by the ticksToNanoseconds method is calculated as
      return ticks * 1000000000 / counterFrequency;
      and this causes our problem

      we replaced the code with
      static inline qint64 ticksToNanoseconds(qint64 ticks)
      {
      if (counterFrequency > 0)

      { quint64 secs = ticks/counterFrequency; quint64 nano = ((ticks%counterFrequency) * 1000000000) / counterFrequency; // QueryPerformanceCounter uses an arbitrary frequency return (secs * 1000000000) + nano; }

      else

      { // GetTickCount(64) return milliseconds return ticks * 1000000; }

      }

      this will solve our problems until we have a counterfrequency that reaches 16GHz...

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            w00t Robin Burchell
            Reporter:
            david_heremans David Heremans
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes