From 0c2fabd28c68094a490461c06b085ed7d00f8a14 Mon Sep 17 00:00:00 2001 From: yfprojects <62463991+real-yfprojects@users.noreply.github.com> Date: Wed, 23 Mar 2022 06:14:18 +0000 Subject: [PATCH] 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. --- src/vorta/scheduler.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/vorta/scheduler.py b/src/vorta/scheduler.py index 99d4f66f..bb56491c 100644 --- a/src/vorta/scheduler.py +++ b/src/vorta/scheduler.py @@ -149,17 +149,24 @@ def set_timer_for_profile(self, profile_id: int): minute=profile.schedule_fixed_minute) # start QTimer - logger.debug('Scheduling next run for %s', next_time) - timer_ms = (next_time - dt.now()).total_seconds() * 1000 - timer = QtCore.QTimer() - timer.setSingleShot(True) - timer.setInterval(int(timer_ms)) - timer.timeout.connect(lambda: self.create_backup(profile_id)) - timer.start() + if timer_ms < 2**31 - 1: + logger.debug('Scheduling next run for %s', next_time) - self.timers[profile_id] = {'qtt': timer, 'dt': next_time} + timer = QtCore.QTimer() + timer.setSingleShot(True) + timer.setInterval(int(timer_ms)) + timer.timeout.connect(lambda: self.create_backup(profile_id)) + timer.start() + + 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 self.schedule_changed.emit(profile_id)