Skip to content

Commit

Permalink
check more timers
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Compiler committed May 7, 2024
1 parent 01cc3df commit 31ab343
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
- testenv: py312-pyqt67
os: ubuntu-22.04
python: "3.12"
args: -x -s "tests/end2end/features/"
args: "tests/end2end/features/"
### Windows
- testenv: py312-pyqt67
os: windows-2019
python: "3.12"
args: -x -s "tests/end2end/features/"
args: "tests/end2end/features/"
runs-on: "${{ matrix.os }}"
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion qutebrowser/browser/webengine/webenginetab.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ def __init__(self, tab, parent=None):
# Implements the intended two-second delay specified at
# https://doc.qt.io/archives/qt-5.14/qwebenginepage.html#recentlyAudibleChanged
delay_ms = 2000
self._silence_timer = QTimer(self)
self._silence_timer = usertypes.Timer(self)
self._silence_timer.setSingleShot(True)
self._silence_timer.setInterval(delay_ms)

Expand Down
4 changes: 2 additions & 2 deletions qutebrowser/completion/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from qutebrowser.config import config
from qutebrowser.commands import parser, cmdexc
from qutebrowser.misc import objects, split
from qutebrowser.utils import log, utils, debug, objreg
from qutebrowser.utils import log, utils, debug, objreg, usertypes
from qutebrowser.completion.models import miscmodels
from qutebrowser.completion import completionwidget
if TYPE_CHECKING:
Expand Down Expand Up @@ -49,7 +49,7 @@ def __init__(self, *, cmd, win_id, parent=None):
super().__init__(parent)
self._cmd = cmd
self._win_id = win_id
self._timer = QTimer()
self._timer = usertypes.Timer()
self._timer.setSingleShot(True)
self._timer.setInterval(0)
self._timer.timeout.connect(self._update_completion)
Expand Down
2 changes: 1 addition & 1 deletion qutebrowser/mainwindow/messageview.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(self, parent=None):
self._vbox.setSpacing(0)
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)

self._clear_timer = QTimer()
self._clear_timer = usertypes.Timer()
self._clear_timer.timeout.connect(self.clear_messages)
config.instance.changed.connect(self._set_clear_timer_interval)

Expand Down
3 changes: 2 additions & 1 deletion qutebrowser/mainwindow/statusbar/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from qutebrowser.qt.core import Qt, QTimer

from qutebrowser.mainwindow.statusbar import textbase
from qutebrowser.utils import usertypes


class Clock(textbase.TextBase):
Expand All @@ -20,7 +21,7 @@ def __init__(self, parent=None):
super().__init__(parent, elidemode=Qt.TextElideMode.ElideNone)
self.format = ""

self.timer = QTimer(self)
self.timer = usertypes.Timer(self)
self.timer.timeout.connect(self._show_time)

def _show_time(self):
Expand Down
2 changes: 1 addition & 1 deletion qutebrowser/mainwindow/tabwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def __init__(self, win_id, parent=None):
self.setStyle(self._our_style)
self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.vertical = False
self._auto_hide_timer = QTimer()
self._auto_hide_timer = usertypes.Timer()
self._auto_hide_timer.setSingleShot(True)
self._auto_hide_timer.timeout.connect(self.maybe_hide)
self._on_show_switching_delay_changed()
Expand Down
4 changes: 2 additions & 2 deletions qutebrowser/misc/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from qutebrowser.qt.network import (QNetworkAccessManager, QNetworkRequest,
QNetworkReply)

from qutebrowser.utils import qtlog
from qutebrowser.utils import qtlog, usertypes


class HTTPRequest(QNetworkRequest):
Expand Down Expand Up @@ -85,7 +85,7 @@ def _handle_reply(self, reply):
if reply.isFinished():
self.on_reply_finished(reply)
else:
timer = QTimer(self)
timer = usertypes.Timer(self)
timer.setInterval(10000)
timer.timeout.connect(reply.abort)
timer.start()
Expand Down
4 changes: 2 additions & 2 deletions qutebrowser/utils/usertypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,9 @@ def _check_timeout_validity(self) -> None:
# manual emission?
return
elapsed = time.monotonic() - self._start_time
if elapsed < self.interval() / 1000 / 2:
if elapsed < self.interval() / 1000 / 2 and self._name != "ipc-timeout":
log.misc.warning(
f"Timer {self._name} (id {self.timerId()} triggered too early: "
f"Timer {self._name} (id {self.timerId()}) triggered too early: "
f"interval {self.interval()} but only {elapsed:.3f}s passed")

def setInterval(self, msec: int) -> None:
Expand Down

0 comments on commit 31ab343

Please sign in to comment.