summaryrefslogtreecommitdiff
path: root/qutebrowser/misc/crashsignal.py
diff options
context:
space:
mode:
Diffstat (limited to 'qutebrowser/misc/crashsignal.py')
-rw-r--r--qutebrowser/misc/crashsignal.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py
index d94d3ec54..ccfd51276 100644
--- a/qutebrowser/misc/crashsignal.py
+++ b/qutebrowser/misc/crashsignal.py
@@ -31,15 +31,12 @@ import threading
import faulthandler
import dataclasses
from typing import TYPE_CHECKING, Optional, MutableMapping, cast, List
-
-from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QObject,
- QSocketNotifier, QTimer, QUrl)
-from PyQt5.QtWidgets import QApplication
+from qutebrowser.qt import QtWidgets
from qutebrowser.api import cmdutils
from qutebrowser.misc import earlyinit, crashdialog, ipc, objects
from qutebrowser.utils import usertypes, standarddir, log, objreg, debug, utils
-from qutebrowser.qt import sip
+from qutebrowser.qt import QtCore, sip
if TYPE_CHECKING:
from qutebrowser.misc import quitter
@@ -57,7 +54,7 @@ class ExceptionInfo:
crash_handler = cast('CrashHandler', None)
-class CrashHandler(QObject):
+class CrashHandler(QtCore.QObject):
"""Handler for crashes, reports and exceptions.
@@ -135,7 +132,7 @@ class CrashHandler(QObject):
for tab in tabbed_browser.widgets():
try:
urlstr = tab.url().toString(
- QUrl.RemovePassword | QUrl.FullyEncoded)
+ QtCore.QUrl.RemovePassword | QtCore.QUrl.FullyEncoded)
if urlstr:
win_pages.append(urlstr)
except Exception:
@@ -178,7 +175,7 @@ class CrashHandler(QObject):
else:
self._crash_dialog.report(info=info, contact=contact)
- @pyqtSlot()
+ @QtCore.pyqtSlot()
def shutdown(self):
self.destroy_crashlogfile()
@@ -303,7 +300,7 @@ class CrashHandler(QObject):
# We might risk a segfault here, but that's better than continuing to
# run in some undefined state, so we only do the most needed shutdown
# here.
- qInstallMessageHandler(None)
+ QtCore.qInstallMessageHandler(None)
self.destroy_crashlogfile()
sys.exit(usertypes.Exit.exception)
@@ -313,7 +310,7 @@ class CrashHandler(QObject):
self._crash_dialog.raise_()
-class SignalHandler(QObject):
+class SignalHandler(QtCore.QObject):
"""Handler responsible for handling OS signals (SIGINT, SIGTERM, etc.).
@@ -358,8 +355,8 @@ class SignalHandler(QObject):
for fd in [read_fd, write_fd]:
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
- self._notifier = QSocketNotifier(cast(sip.voidptr, read_fd),
- QSocketNotifier.Read,
+ self._notifier = QtCore.QSocketNotifier(cast(sip.voidptr, read_fd),
+ QtCore.QSocketNotifier.Read,
self)
self._notifier.activated.connect( # type: ignore[attr-defined]
self.handle_signal_wakeup)
@@ -386,7 +383,7 @@ class SignalHandler(QObject):
self._timer.stop()
self._activated = False
- @pyqtSlot()
+ @QtCore.pyqtSlot()
def handle_signal_wakeup(self):
"""Handle a newly arrived signal.
@@ -407,7 +404,7 @@ class SignalHandler(QObject):
def _log_later(self, *lines):
"""Log the given text line-wise with a QTimer."""
for line in lines:
- QTimer.singleShot(0, functools.partial(log.destroy.info, line))
+ QtCore.QTimer.singleShot(0, functools.partial(log.destroy.info, line))
def interrupt(self, signum, _frame):
"""Handler for signals to gracefully shutdown (SIGINT/SIGTERM).
@@ -420,7 +417,7 @@ class SignalHandler(QObject):
# Signals can arrive anywhere, so we do this in the main thread
self._log_later("SIGINT/SIGTERM received, shutting down!",
"Do the same again to forcefully quit.")
- QTimer.singleShot(0, functools.partial(
+ QtCore.QTimer.singleShot(0, functools.partial(
self._quitter.shutdown, 128 + signum))
def interrupt_forcefully(self, signum, _frame):
@@ -435,7 +432,7 @@ class SignalHandler(QObject):
# Signals can arrive anywhere, so we do this in the main thread
self._log_later("Forceful quit requested, goodbye cruel world!",
"Do the same again to quit with even more force.")
- QTimer.singleShot(0, functools.partial(self._app.exit, 128 + signum))
+ QtCore.QTimer.singleShot(0, functools.partial(self._app.exit, 128 + signum))
def interrupt_really_forcefully(self, signum, _frame):
"""Interrupt with even more force on the third SIGINT/SIGTERM request.
@@ -447,7 +444,7 @@ class SignalHandler(QObject):
sys.exit(128 + signum)
-def init(q_app: QApplication,
+def init(q_app: QtWidgets.QApplication,
args: argparse.Namespace,
quitter: 'quitter.Quitter') -> None:
"""Initialize crash/signal handlers."""