From 70faceea67f7ac65c078365616bd090121ff8992 Mon Sep 17 00:00:00 2001
From: Florian Bruhin <git@the-compiler.org>
Date: Wed, 30 Jul 2014 17:05:29 +0200
Subject: [PATCH] Check for overflows in custom Timer

---
 qutebrowser/utils/usertypes.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/qutebrowser/utils/usertypes.py b/qutebrowser/utils/usertypes.py
index 5bdd15329..43b31464d 100644
--- a/qutebrowser/utils/usertypes.py
+++ b/qutebrowser/utils/usertypes.py
@@ -30,6 +30,7 @@ import enum as pyenum
 from PyQt5.QtCore import pyqtSignal, QObject, QTimer
 
 from qutebrowser.utils.log import misc as logger
+from qutebrowser.utils.qt import check_overflow
 
 
 _UNSET = object()
@@ -352,7 +353,7 @@ class Question(QObject):
 
 class Timer(QTimer):
 
-    """A timer which has a name to show in __repr__.
+    """A timer which has a name to show in __repr__ and checks for overflows.
 
     Attributes:
         _name: The name of the timer.
@@ -368,3 +369,16 @@ class Timer(QTimer):
 
     def __repr__(self):
         return '<{} {}>'.format(self.__class__.__name__, self._name)
+
+    def setInterval(self, msec):
+        """Extend setInterval to check for overflows."""
+        check_overflow(msec, 'int')
+        super().setInterval(msec)
+
+    def start(self, msec=None):
+        """Extend start to check for overflows."""
+        if msec is not None:
+            check_overflow(msec, 'int')
+            super().start(msec)
+        else:
+            super().start()