mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-23 18:58:29 +03:00
Fixed issue with timer drift.
This commit is contained in:
parent
17bcc80bd5
commit
d5803b9fb6
2
NEWS
2
NEWS
@ -1,4 +1,6 @@
|
||||
* Version 2.2.2 (unreleased)
|
||||
** Re-schedule timer each time period based on system time to prevent Qt timer
|
||||
drift.
|
||||
|
||||
* Version 2.2.1 (released 2015-08-20)
|
||||
** Bugfix release: Fix adding credentials via the UI.
|
||||
|
@ -152,17 +152,14 @@ class Timer(QtCore.QObject):
|
||||
|
||||
now = time()
|
||||
rem = now % interval
|
||||
QtCore.QTimer.singleShot((self._interval - rem) * 1000, self.start_timer)
|
||||
self._time = int(now - rem)
|
||||
QtCore.QTimer.singleShot((self._interval - rem) * 1000, self._tick)
|
||||
|
||||
def start_timer(self):
|
||||
self.startTimer(self._interval * 1000)
|
||||
self.timerEvent(QtCore.QEvent(QtCore.QEvent.None))
|
||||
|
||||
def timerEvent(self, event):
|
||||
def _tick(self):
|
||||
self._time += self._interval
|
||||
self.time_changed.emit(self._time)
|
||||
event.accept()
|
||||
next_time = self._time + self._interval
|
||||
QtCore.QTimer.singleShot((next_time - time()) * 1000, self._tick)
|
||||
|
||||
@property
|
||||
def time(self):
|
||||
|
Loading…
Reference in New Issue
Block a user