From b42d701b0cf6c10e948e5da1b4e440ebcad72895 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 10 Oct 2014 07:45:44 +0200 Subject: [PATCH] debug-console: Only create when needed --- qutebrowser/app.py | 5 +---- qutebrowser/utils/utilcmds.py | 8 +++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 401ac1a28..10e0119e6 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -40,7 +40,7 @@ from qutebrowser.commands import cmdutils, runners from qutebrowser.config import style, config, websettings from qutebrowser.network import qutescheme, proxy from qutebrowser.browser import quickmarks, cookies, downloads, cache -from qutebrowser.widgets import mainwindow, console, crash +from qutebrowser.widgets import mainwindow, crash from qutebrowser.keyinput import modeman from qutebrowser.utils import (log, version, message, readline, utils, qtutils, urlutils, debug, objreg, usertypes, standarddir) @@ -161,9 +161,6 @@ class Application(QApplication): False if self._args.nowindow else True) main_window = objreg.get('main-window', scope='window', window=win_id) self.setActiveWindow(main_window) - log.init.debug("Initializing debug console...") - debug_console = console.ConsoleWidget() - objreg.register('debug-console', debug_console) def _handle_segfault(self): """Handle a segfault from a previous run.""" diff --git a/qutebrowser/utils/utilcmds.py b/qutebrowser/utils/utilcmds.py index 05c167dd0..575a892d7 100644 --- a/qutebrowser/utils/utilcmds.py +++ b/qutebrowser/utils/utilcmds.py @@ -27,6 +27,7 @@ from PyQt5.QtCore import QCoreApplication from qutebrowser.utils import log, objreg, usertypes from qutebrowser.commands import cmdutils, runners, cmdexc from qutebrowser.config import style +from qutebrowser.widgets import console @cmdutils.register(scope='window') @@ -111,4 +112,9 @@ def debug_cache_stats(): @cmdutils.register(debug=True) def debug_console(): """Show the debugging console.""" - objreg.get('debug-console').show() + try: + debug_console = objreg.get('debug-console') + except KeyError: + debug_console = console.ConsoleWidget() + objreg.register('debug-console', debug_console) + debug_console.show()