Improve crashdialog result codes

This commit is contained in:
Florian Bruhin 2017-09-27 11:46:51 +02:00
parent 6573888dc6
commit fac322058e
2 changed files with 8 additions and 4 deletions

View File

@ -35,12 +35,16 @@ from PyQt5.QtWidgets import (QDialog, QLabel, QTextEdit, QPushButton,
QDialogButtonBox, QApplication) QDialogButtonBox, QApplication)
import qutebrowser 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, from qutebrowser.misc import (miscwidgets, autoupdate, msgbox, httpclient,
pastebin) pastebin)
from qutebrowser.config import config, configfiles 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): def parse_fatal_stacktrace(text):
"""Get useful information from a fatal faulthandler stacktrace. """Get useful information from a fatal faulthandler stacktrace.
@ -443,9 +447,9 @@ class ExceptionCrashDialog(_CrashDialog):
def finish(self): def finish(self):
self._save_contact_info() self._save_contact_info()
if self._chk_restore.isChecked(): if self._chk_restore.isChecked():
self.accept() self.done(Result.restore)
else: else:
self.reject() self.done(Result.no_restore)
class FatalCrashDialog(_CrashDialog): class FatalCrashDialog(_CrashDialog):

View File

@ -258,7 +258,7 @@ class CrashHandler(QObject):
self._args.debug, info.pages, info.cmd_history, exc, self._args.debug, info.pages, info.cmd_history, exc,
info.objects) info.objects)
ret = self._crash_dialog.exec_() ret = self._crash_dialog.exec_()
if ret == QDialog.Accepted: # restore if ret == crashdialog.Result.restore:
self._quitter.restart(info.pages) self._quitter.restart(info.pages)
# We might risk a segfault here, but that's better than continuing to # We might risk a segfault here, but that's better than continuing to