Merge branch 'master' of ssh://lupin/qutebrowser

Conflicts:
	TODO
This commit is contained in:
Florian Bruhin 2014-05-08 07:00:40 +02:00
commit fce2085ea9
4 changed files with 30 additions and 22 deletions

5
TODO
View File

@ -11,8 +11,6 @@ Before 0.1
- Autosave feature (against segfaults/...)
- Save tabs feature
- More dwb keybindings
- Filter events in QMainWindow, not QApplication
or at least release them when opening other windows, e.g. print dialog
- Use :open engine searchterm syntax for searching
Crashes
@ -66,6 +64,9 @@ Bugs
- Sometimes there's a horizontal scrollbar in the completer
- Eliding doesn't work correctly in tabs (cuts off start)
This especially happens when there's no favicon
Style
=====

View File

@ -135,6 +135,7 @@ class QuteBrowser(QApplication):
self._init_cmds()
self.mainwindow = MainWindow()
self.modeman.mainwindow = self.mainwindow
self.installEventFilter(self.modeman)
self.setQuitOnLastWindowClosed(False)
@ -397,15 +398,6 @@ class QuteBrowser(QApplication):
exc = (exctype, excvalue, tb)
sys.__excepthook__(*exc)
self._quit_status['crash'] = False
# Give key input back for crash dialog
try:
self.removeEventFilter(self.modeman)
except AttributeError:
# self.modeman could be None
pass
if exctype is BdbQuit or not issubclass(exctype, Exception):
# pdb exit, KeyboardInterrupt, ...
try:
@ -413,6 +405,9 @@ class QuteBrowser(QApplication):
return
except Exception:
self.quit()
self._quit_status['crash'] = False
try:
pages = self._recover_pages()
except Exception:
@ -447,7 +442,9 @@ class QuteBrowser(QApplication):
logging.debug("Running {} with args {}".format(sys.executable,
argv))
subprocess.Popen(argv)
self._maybe_quit('crash')
# We might risk a segfault here, but that's better than continuing to
# run in some undefined state.
sys.exit(1)
def _maybe_quit(self, sender):
"""Maybe quit qutebrowser.

View File

@ -62,6 +62,7 @@ class ModeManager(QObject):
Attributes:
mode: The current mode (readonly property).
passthrough: A list of modes in which to pass through events.
mainwindow: The mainwindow object
_handlers: A dictionary of modes and their handlers.
_mode_stack: A list of the modes we're currently in, with the active
one on the right.
@ -84,6 +85,7 @@ class ModeManager(QObject):
def __init__(self, parent=None):
super().__init__(parent)
self.mainwindow = None
self._handlers = {}
self.passthrough = []
self._mode_stack = []
@ -94,6 +96,18 @@ class ModeManager(QObject):
@property
def mode(self):
"""Read-only property for the current mode."""
# For some reason, on Ubuntu (Python 3.3.2, PyQt 5.0.1, Qt 5.0.2) there
# is a lingering exception here sometimes. With this construct, we
# clear this exception which makes no sense at all anyways.
# Details:
# http://www.riverbankcomputing.com/pipermail/pyqt/2014-May/034196.html
# If we wouldn't clear the exception, we would actually get an
# AttributeError for the mode property in eventFilter because of
# another PyQt oddity.
try:
raise
except: # pylint: disable=bare-except
pass
if not self._mode_stack:
return None
return self._mode_stack[-1]
@ -228,14 +242,7 @@ class ModeManager(QObject):
Emit:
key_pressed: When a key was actually pressed.
"""
if not hasattr(self, 'mode'):
# FIXME I have no idea how this could possibly happen, but on
# Ubuntu it does on startup.
# self.mode is a simple @property and we certainly don't delete it,
# so this all makes no sense at all.
logging.warn("eventFilter called but self.mode doesn't exist!")
return False
elif self.mode is None:
if self.mode is None:
# We got events before mode is set, so just pass them through.
return False
typ = event.type()
@ -248,7 +255,10 @@ class ModeManager(QObject):
logging.debug("Ignoring event {} for {}".format(
debug.EVENTS[typ], obj.__class__.__name__))
return False
if QApplication.instance().activeWindow() is not self.mainwindow:
# Some other window (print dialog, etc.) is focused so we pass
# the event through.
return False
logging.debug("Got event {} for {} in mode {}".format(
debug.EVENTS[typ], obj.__class__.__name__, self.mode))

View File

@ -45,7 +45,7 @@ _HTML_TEMPLATE = """
"""
pyeval_output = None
pyeval_output = ":pyeval was never called"
def _get_html(title, snippet):