Ignore click events with invalid positions

Since Qt 5.11.2, various crash logs like this popped up after clicking a
<select> element:

    Traceback (most recent call last):
      File ".../browser/mouse.py", line 239, in eventFilter
        return self._handlers[evtype](event)
      File ".../browser/mouse.py", line 121, in _handle_mouse_press
        self._mousepress_insertmode_cb)
      File ".../browser/webengine/webenginetab.py", line 624, in find_at_pos
        assert pos.x() >= 0
    AssertionError

This is probably caused by https://codereview.qt-project.org/#/c/193908/ in
some way...
This commit is contained in:
Florian Bruhin 2018-09-30 22:55:17 +02:00
parent dd41bc2f7b
commit a3ae950707
3 changed files with 9 additions and 4 deletions

View File

@ -96,6 +96,7 @@ Fixed
- Crash when doing initial run on Wayland without XWayland
- Crash when trying to load an empty session file.
- `:hint` with an invalid `--mode=` value now shows a proper error.
- Rare crash on Qt 5.11.2 when clicking on `<select>` elements.
Removed
~~~~~~~

View File

@ -116,9 +116,13 @@ class MouseEventFilter(QObject):
self._ignore_wheel_event = True
pos = e.pos()
if pos.x() < 0 or pos.y() < 0:
log.mouse.warning("Ignoring invalid click at {}".format(pos))
return False
if e.button() != Qt.NoButton:
self._tab.elements.find_at_pos(e.pos(),
self._mousepress_insertmode_cb)
self._tab.elements.find_at_pos(pos, self._mousepress_insertmode_cb)
return False

View File

@ -631,8 +631,8 @@ class WebEngineElements(browsertab.AbstractElements):
self._tab.run_js_async(js_code, js_cb)
def find_at_pos(self, pos, callback):
assert pos.x() >= 0
assert pos.y() >= 0
assert pos.x() >= 0, pos
assert pos.y() >= 0, pos
pos /= self._tab.zoom.factor()
js_code = javascript.assemble('webelem', 'find_at_pos',
pos.x(), pos.y())