QtWebEngine: Fix crash with userscript + selection
Fixes #1878 Unfortunately it seems impossible to implement a test for this, as selection via javascript somehow doesn't trigger this.
This commit is contained in:
parent
d8492fef61
commit
44d6db4f45
@ -42,7 +42,8 @@ In `command` mode:
|
||||
- `QUTE_URL`: The current URL.
|
||||
- `QUTE_TITLE`: The title of the current page.
|
||||
- `QUTE_SELECTED_TEXT`: The text currently selected on the page.
|
||||
- `QUTE_SELECTED_HTML` The HTML currently selected on the page.
|
||||
- `QUTE_SELECTED_HTML` The HTML currently selected on the page (not supported
|
||||
with QtWebEngine).
|
||||
|
||||
In `hints` mode:
|
||||
|
||||
|
@ -60,6 +60,11 @@ class WebTabError(Exception):
|
||||
"""Base class for various errors."""
|
||||
|
||||
|
||||
class UnsupportedOperationError(WebTabError):
|
||||
|
||||
"""Raised when an operation is not supported with the given backend."""
|
||||
|
||||
|
||||
class TabData:
|
||||
|
||||
"""A simple namespace with a fixed set of attributes.
|
||||
|
@ -1089,7 +1089,10 @@ class CommandDispatcher:
|
||||
tab = self._tabbed_browser.currentWidget()
|
||||
if tab is not None and tab.caret.has_selection():
|
||||
env['QUTE_SELECTED_TEXT'] = tab.caret.selection()
|
||||
env['QUTE_SELECTED_HTML'] = tab.caret.selection(html=True)
|
||||
try:
|
||||
env['QUTE_SELECTED_HTML'] = tab.caret.selection(html=True)
|
||||
except browsertab.UnsupportedOperationError:
|
||||
pass
|
||||
|
||||
# FIXME:qtwebengine: If tab is None, run_async will fail!
|
||||
|
||||
|
@ -171,7 +171,7 @@ class WebEngineCaret(browsertab.AbstractCaret):
|
||||
|
||||
def selection(self, html=False):
|
||||
if html:
|
||||
raise NotImplementedError
|
||||
raise browsertab.UnsupportedOperationError
|
||||
return self._widget.selectedText()
|
||||
|
||||
def follow_selected(self, *, tab=False):
|
||||
|
Loading…
Reference in New Issue
Block a user