From a2809e76bb77ffcd169b2c63c3d8c6ac2ea2cdcc Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 31 Oct 2014 07:05:04 +0100 Subject: [PATCH] Handle --debug specially --- qutebrowser/app.py | 6 +++--- qutebrowser/widgets/crash.py | 41 +++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 357da6ba5..03dcb3794 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -188,7 +188,7 @@ class Application(QApplication): if data: # Crashlog exists and has data in it, so something crashed # previously. - self._crashdlg = crash.FatalCrashDialog(data) + self._crashdlg = crash.FatalCrashDialog(self._args.debug, data) self._crashdlg.show() else: # There's no log file, so we can use this to display crashes to the @@ -485,8 +485,8 @@ class Application(QApplication): except TypeError: log.destroy.exception("Error while preventing shutdown") QApplication.closeAllWindows() - self._crashdlg = crash.ExceptionCrashDialog(pages, history, exc, - objects) + self._crashdlg = crash.ExceptionCrashDialog( + self._args.debug, pages, history, exc, objects) ret = self._crashdlg.exec_() if ret == QDialog.Accepted: # restore self.restart(shutdown=False, pages=pages) diff --git a/qutebrowser/widgets/crash.py b/qutebrowser/widgets/crash.py index 1d0de7229..ca6e78324 100644 --- a/qutebrowser/widgets/crash.py +++ b/qutebrowser/widgets/crash.py @@ -48,8 +48,12 @@ class _CrashDialog(QDialog): _crash_info: A list of tuples with title and crash information. """ - def __init__(self, parent=None): - """Constructor for CrashDialog.""" + def __init__(self, debug, parent=None): + """Constructor for CrashDialog. + + Args: + debug: Whether --debug was given. + """ super().__init__(parent) # We don't set WA_DeleteOnClose here as on an exception, we'll get # closed anyways, and it only could have unintended side-effects. @@ -78,19 +82,21 @@ class _CrashDialog(QDialog): self._vbox.addSpacing(15) self._debug_log = QTextEdit(tabChangesFocus=True) + self._debug_log.hide() info = QLabel("You can edit the log below to remove sensitive " "information.", wordWrap=True) info.hide() self._fold = DetailFold("Show log", self) self._fold.toggled.connect(self._debug_log.setVisible) self._fold.toggled.connect(info.setVisible) + if debug: + self._fold.toggle() self._vbox.addWidget(self._fold) self._vbox.addWidget(info) self._vbox.addWidget(self._debug_log, 10) - self._debug_log.hide() self._vbox.addSpacing(15) - self._init_checkboxes() + self._init_checkboxes(debug) self._init_buttons() def __repr__(self): @@ -104,13 +110,15 @@ class _CrashDialog(QDialog): self._lbl.setWordWrap(True) self._vbox.addWidget(self._lbl) - def _init_checkboxes(self): + def _init_checkboxes(self, debug): """Initialize the checkboxes. - Should be overwritten by subclasses. + Args: + debug: Whether a --debug arg was given. """ self._chk_report = QCheckBox("Send a report") - self._chk_report.setChecked(True) + if not debug: + self._chk_report.setChecked(True) self._vbox.addWidget(self._chk_report) info_label = QLabel("Note that without your help, I can't fix the " "bug you encountered.", wordWrap=True) @@ -204,8 +212,8 @@ class ExceptionCrashDialog(_CrashDialog): _objects: A list of all QObjects as string. """ - def __init__(self, pages, cmdhist, exc, objects, parent=None): - super().__init__(parent) + def __init__(self, debug, pages, cmdhist, exc, objects, parent=None): + super().__init__(debug, parent) self._pages = pages self._cmdhist = cmdhist self._exc = exc @@ -232,11 +240,14 @@ class ExceptionCrashDialog(_CrashDialog): self._buttons = [btn_quit, btn_restart] - def _init_checkboxes(self): + def _init_checkboxes(self, debug): """Add checkboxes to send crash report.""" - super()._init_checkboxes() + super()._init_checkboxes(debug) self._chk_log = QCheckBox("Include a debug log and a list of open " "pages", checked=True) + if debug: + self._chk_log.setChecked(False) + self._chk_log.setEnabled(False) self._chk_log.toggled.connect(self._set_crash_info) self._vbox.addWidget(self._chk_log) info_label = QLabel("This makes it a lot easier to diagnose the " @@ -281,8 +292,8 @@ class FatalCrashDialog(_CrashDialog): _log: The log text to display. """ - def __init__(self, text, parent=None): - super().__init__(parent) + def __init__(self, debug, text, parent=None): + super().__init__(debug, parent) self._log = text self.setAttribute(Qt.WA_DeleteOnClose) self._set_crash_info() @@ -318,7 +329,7 @@ class ReportDialog(_CrashDialog): """ def __init__(self, pages, cmdhist, objects, parent=None): - super().__init__(parent) + super().__init__(False, parent) self.setAttribute(Qt.WA_DeleteOnClose) self._btn_report = None self._pages = pages @@ -338,7 +349,7 @@ class ReportDialog(_CrashDialog): self._btn_report.clicked.connect(self.close) self._hbox.addWidget(self._btn_report) - def _init_checkboxes(self): + def _init_checkboxes(self, _debug): """We don't want any checkboxes as the user wanted to report.""" pass