mirror of
https://github.com/borgbase/vorta
synced 2025-01-03 13:45:49 +00:00
Fix setting a timer value too large for C++ int. (#1230)
Fixes #1227. Set timer only if value is smaller than `2**31-1` = 2147483647 else do nothing. Every 15 min vorta will trigger a reschedule.
This commit is contained in:
parent
0a78bd5342
commit
0c2fabd28c
1 changed files with 15 additions and 8 deletions
|
@ -149,10 +149,11 @@ def set_timer_for_profile(self, profile_id: int):
|
||||||
minute=profile.schedule_fixed_minute)
|
minute=profile.schedule_fixed_minute)
|
||||||
|
|
||||||
# start QTimer
|
# start QTimer
|
||||||
logger.debug('Scheduling next run for %s', next_time)
|
|
||||||
|
|
||||||
timer_ms = (next_time - dt.now()).total_seconds() * 1000
|
timer_ms = (next_time - dt.now()).total_seconds() * 1000
|
||||||
|
|
||||||
|
if timer_ms < 2**31 - 1:
|
||||||
|
logger.debug('Scheduling next run for %s', next_time)
|
||||||
|
|
||||||
timer = QtCore.QTimer()
|
timer = QtCore.QTimer()
|
||||||
timer.setSingleShot(True)
|
timer.setSingleShot(True)
|
||||||
timer.setInterval(int(timer_ms))
|
timer.setInterval(int(timer_ms))
|
||||||
|
@ -160,6 +161,12 @@ def set_timer_for_profile(self, profile_id: int):
|
||||||
timer.start()
|
timer.start()
|
||||||
|
|
||||||
self.timers[profile_id] = {'qtt': timer, 'dt': next_time}
|
self.timers[profile_id] = {'qtt': timer, 'dt': next_time}
|
||||||
|
else:
|
||||||
|
# int to big to pass it to qt which expects a c++ int
|
||||||
|
# wait 15 min for regular reschedule
|
||||||
|
logger.debug(
|
||||||
|
f"Couldn't schedule for {next_time} because" +
|
||||||
|
f"timer value {timer_ms} too large.")
|
||||||
|
|
||||||
# Emit signal so that e.g. the GUI can react to the new schedule
|
# Emit signal so that e.g. the GUI can react to the new schedule
|
||||||
self.schedule_changed.emit(profile_id)
|
self.schedule_changed.emit(profile_id)
|
||||||
|
|
Loading…
Reference in a new issue