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