From fac322058ec54969c55934c0712ff3c06c58ca95 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 27 Sep 2017 11:46:51 +0200 Subject: [PATCH] Improve crashdialog result codes --- qutebrowser/misc/crashdialog.py | 10 +++++++--- qutebrowser/misc/crashsignal.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py index 49c17ccd4..60c83d36b 100644 --- a/qutebrowser/misc/crashdialog.py +++ b/qutebrowser/misc/crashdialog.py @@ -35,12 +35,16 @@ from PyQt5.QtWidgets import (QDialog, QLabel, QTextEdit, QPushButton, QDialogButtonBox, QApplication) import qutebrowser -from qutebrowser.utils import version, log, utils, objreg +from qutebrowser.utils import version, log, utils, objreg, usertypes from qutebrowser.misc import (miscwidgets, autoupdate, msgbox, httpclient, pastebin) from qutebrowser.config import config, configfiles +Result = usertypes.enum('Result', ['restore', 'no_restore'], is_int=True, + start=QDialog.Accepted + 1) + + def parse_fatal_stacktrace(text): """Get useful information from a fatal faulthandler stacktrace. @@ -443,9 +447,9 @@ class ExceptionCrashDialog(_CrashDialog): def finish(self): self._save_contact_info() if self._chk_restore.isChecked(): - self.accept() + self.done(Result.restore) else: - self.reject() + self.done(Result.no_restore) class FatalCrashDialog(_CrashDialog): diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py index da47b6f43..186bd9103 100644 --- a/qutebrowser/misc/crashsignal.py +++ b/qutebrowser/misc/crashsignal.py @@ -258,7 +258,7 @@ class CrashHandler(QObject): self._args.debug, info.pages, info.cmd_history, exc, info.objects) ret = self._crash_dialog.exec_() - if ret == QDialog.Accepted: # restore + if ret == crashdialog.Result.restore: self._quitter.restart(info.pages) # We might risk a segfault here, but that's better than continuing to