Handle not being able to get elements via JS

This commit is contained in:
Florian Bruhin 2016-11-13 01:46:18 +01:00
parent 645a9aa6e1
commit 5bdd74138d
3 changed files with 13 additions and 0 deletions

View File

@ -566,6 +566,10 @@ class HintManager(QObject):
def _start_cb(self, elems):
"""Initialize the elements and labels based on the context set."""
if elems is None:
message.error("There was an error while getting hint elements")
return
filterfunc = webelem.FILTERS.get(self._context.group, lambda e: True)
elems = [e for e in elems if filterfunc(e)]
if not elems:

View File

@ -112,6 +112,10 @@ def prevnext(*, browsertab, win_id, baseurl, prev=False,
window: True to open in a new window, False for the current one.
"""
def _prevnext_cb(elems):
if elems is None:
message.error("There was an error while getting hint elements")
return
elem = _find_prevnext(prev, elems)
word = 'prev' if prev else 'forward'

View File

@ -392,8 +392,13 @@ class WebEngineElements(browsertab.AbstractElements):
Args:
callback: The callback to call with the found elements.
Called with None if there was an error.
js_elems: The elements serialized from javascript.
"""
if js_elems is None:
callback(None)
return
elems = []
for js_elem in js_elems:
elem = webengineelem.WebEngineElement(js_elem, tab=self._tab)