Merge get_all_widgets into get_all_objects.
This commit is contained in:
parent
30209f531e
commit
aa681f5ad2
@ -460,15 +460,11 @@ class Application(QApplication):
|
||||
tabs.start_download.connect(self.downloadmanager.fetch)
|
||||
tabs.download_get.connect(self.downloadmanager.get)
|
||||
|
||||
def get_all_widgets(self):
|
||||
def _get_widgets(self):
|
||||
"""Get a string list of all widgets."""
|
||||
lines = []
|
||||
widgets = self.allWidgets()
|
||||
widgets.sort(key=lambda e: repr(e))
|
||||
lines.append("{} widgets".format(len(widgets)))
|
||||
for w in widgets:
|
||||
lines.append(repr(w))
|
||||
return '\n'.join(lines)
|
||||
return [repr(w) for w in widgets]
|
||||
|
||||
def _get_pyqt_objects(self, lines, obj, depth=0):
|
||||
"""Recursive method for get_all_objects to get Qt objects."""
|
||||
@ -500,6 +496,12 @@ class Application(QApplication):
|
||||
pyqt_lines.insert(0, 'Qt objects - {} objects:'.format(
|
||||
len(pyqt_lines)))
|
||||
output += pyqt_lines
|
||||
output += ['']
|
||||
widget_lines = self._get_widgets()
|
||||
widget_lines = [' ' + e for e in widget_lines]
|
||||
widget_lines.insert(0, "Qt widgets - {} objects".format(
|
||||
len(widget_lines)))
|
||||
output += widget_lines
|
||||
return '\n'.join(output)
|
||||
|
||||
def _recover_pages(self):
|
||||
@ -587,12 +589,6 @@ class Application(QApplication):
|
||||
log.destroy.exception("Error while getting history: {}")
|
||||
history = []
|
||||
|
||||
try:
|
||||
widgets = self.get_all_widgets()
|
||||
except Exception:
|
||||
log.destroy.exception("Error while getting widgets")
|
||||
widgets = ""
|
||||
|
||||
try:
|
||||
objects = self.get_all_objects()
|
||||
except Exception:
|
||||
@ -605,7 +601,7 @@ class Application(QApplication):
|
||||
log.destroy.exception("Error while preventing shutdown")
|
||||
QApplication.closeAllWindows()
|
||||
self._crashdlg = crash.ExceptionCrashDialog(pages, history, exc,
|
||||
widgets, objects)
|
||||
objects)
|
||||
ret = self._crashdlg.exec_()
|
||||
if ret == QDialog.Accepted: # restore
|
||||
self.restart(shutdown=False, pages=pages)
|
||||
@ -677,9 +673,8 @@ class Application(QApplication):
|
||||
"""Report a bug in qutebrowser."""
|
||||
pages = self._recover_pages()
|
||||
history = self.mainwindow.status.cmd.history[-5:]
|
||||
widgets = self.get_all_widgets()
|
||||
objects = self.get_all_objects()
|
||||
self._crashdlg = crash.ReportDialog(pages, history, widgets, objects)
|
||||
self._crashdlg = crash.ReportDialog(pages, history, objects)
|
||||
self._crashdlg.show()
|
||||
|
||||
@cmdutils.register(instance='', debug=True, name='debug-console')
|
||||
|
@ -86,13 +86,6 @@ def debug_crash(typ: ('exception', 'segfault')='exception'):
|
||||
raise Exception("Forced crash")
|
||||
|
||||
|
||||
@cmdutils.register(debug=True)
|
||||
def debug_all_widgets():
|
||||
"""Print a list of all widgets to debug log."""
|
||||
s = QCoreApplication.instance().get_all_widgets()
|
||||
log.misc.debug(s)
|
||||
|
||||
|
||||
@cmdutils.register(debug=True)
|
||||
def debug_all_objects():
|
||||
"""Print a list of all objects to the debug log."""
|
||||
|
@ -176,18 +176,16 @@ class ExceptionCrashDialog(_CrashDialog):
|
||||
_pages: A list of the open pages (URLs as strings)
|
||||
_cmdhist: A list with the command history (as strings)
|
||||
_exc: An exception tuple (type, value, traceback)
|
||||
_widgets: A list of active widgets as string.
|
||||
_objects: A list of all QObjects as string.
|
||||
"""
|
||||
|
||||
def __init__(self, pages, cmdhist, exc, widgets, objects, parent=None):
|
||||
def __init__(self, pages, cmdhist, exc, objects, parent=None):
|
||||
self._pages = pages
|
||||
self._cmdhist = cmdhist
|
||||
self._exc = exc
|
||||
self._btn_quit = None
|
||||
self._btn_restore = None
|
||||
self._btn_pastebin = None
|
||||
self._widgets = widgets
|
||||
self._objects = objects
|
||||
super().__init__(parent)
|
||||
self.setModal(True)
|
||||
@ -225,7 +223,6 @@ class ExceptionCrashDialog(_CrashDialog):
|
||||
("Commandline args", ' '.join(sys.argv[1:])),
|
||||
("Open Pages", '\n'.join(self._pages)),
|
||||
("Command history", '\n'.join(self._cmdhist)),
|
||||
("Widgets", self._widgets),
|
||||
("Objects", self._objects),
|
||||
]
|
||||
try:
|
||||
@ -285,16 +282,14 @@ class ReportDialog(_CrashDialog):
|
||||
_btn_pastebin: The pastebin button.
|
||||
_pages: A list of the open pages (URLs as strings)
|
||||
_cmdhist: A list with the command history (as strings)
|
||||
_widgets: A list of active widgets as string.
|
||||
_objects: A list of all QObjects as string.
|
||||
"""
|
||||
|
||||
def __init__(self, pages, cmdhist, widgets, objects, parent=None):
|
||||
def __init__(self, pages, cmdhist, objects, parent=None):
|
||||
self._pages = pages
|
||||
self._cmdhist = cmdhist
|
||||
self._btn_ok = None
|
||||
self._btn_pastebin = None
|
||||
self._widgets = widgets
|
||||
self._objects = objects
|
||||
super().__init__(parent)
|
||||
self.setAttribute(Qt.WA_DeleteOnClose)
|
||||
@ -324,7 +319,6 @@ class ReportDialog(_CrashDialog):
|
||||
("Commandline args", ' '.join(sys.argv[1:])),
|
||||
("Open Pages", '\n'.join(self._pages)),
|
||||
("Command history", '\n'.join(self._cmdhist)),
|
||||
("Widgets", self._widgets),
|
||||
("Objects", self._objects),
|
||||
]
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user