Ignore isNullError while handling label elements.

Fixes #295 (hopefully for real this time!)
This commit is contained in:
Florian Bruhin 2014-12-02 21:16:45 +01:00
parent 99fb516aa3
commit d94f848c82

View File

@ -672,17 +672,22 @@ class HintManager(QObject):
"""Handle a new partial keypress."""
log.hints.debug("Handling new keystring: '{}'".format(keystr))
for (string, elems) in self._context.elems.items():
try:
if string.startswith(keystr):
matched = string[:len(keystr)]
rest = string[len(keystr):]
elems.label.setInnerXml('<font color="{}">{}</font>{}'.format(
config.get('colors', 'hints.fg.match'), matched, rest))
match_color = config.get('colors', 'hints.fg.match')
elems.label.setInnerXml(
'<font color="{}">{}</font>{}'.format(
match_color, matched, rest))
if self._is_hidden(elems.label):
# hidden element which matches again -> unhide it
elems.label.setStyleProperty('display', 'inline')
else:
# element doesn't match anymore -> hide it
elems.label.setStyleProperty('display', 'none')
except webelem.IsNullError:
pass
def filter_hints(self, filterstr):
"""Filter displayed hints according to a text.
@ -691,6 +696,7 @@ class HintManager(QObject):
filterstr: The string to filer with, or None to show all.
"""
for elems in self._context.elems.values():
try:
if (filterstr is None or
str(elems.elem).lower().startswith(filterstr)):
if self._is_hidden(elems.label):
@ -699,6 +705,8 @@ class HintManager(QObject):
else:
# element doesn't match anymore -> hide it
elems.label.setStyleProperty('display', 'none')
except webelem.IsNullError:
pass
visible = {}
for k, e in self._context.elems.items():
if not self._is_hidden(e.label):
@ -779,11 +787,14 @@ class HintManager(QObject):
"""Reposition hints if contents size changed."""
log.hints.debug("Contents size changed...!")
for elems in self._context.elems.values():
try:
if elems.elem.webFrame() is None:
# This sometimes happens for some reason...
elems.label.removeFromDocument()
continue
self._set_style_position(elems.elem, elems.label)
except webelem.IsNullError:
pass
@pyqtSlot(usertypes.KeyMode)
def on_mode_left(self, mode):