mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
prevent cmd+c in webview with empty selection from crashing on macOS
https://forums.ankiweb.net/t/command-c-on-crashes-anki-2-1-41-on-mac/10684
This commit is contained in:
parent
18f8e3743b
commit
d448bd9cb6
1 changed files with 5 additions and 3 deletions
|
@ -288,9 +288,11 @@ class AnkiWebView(QWebEngineView):
|
|||
|
||||
def onCopy(self) -> None:
|
||||
if not self.selectedText():
|
||||
ctx = self._page.contextMenuData()
|
||||
if ctx and ctx.mediaType() == QWebEngineContextMenuData.MediaTypeImage:
|
||||
self.triggerPageAction(QWebEnginePage.CopyImageToClipboard)
|
||||
if not isMac:
|
||||
# crashes on a mac when clicking in the main window and pressing cmd+c
|
||||
ctx = self._page.contextMenuData()
|
||||
if ctx and ctx.mediaType() == QWebEngineContextMenuData.MediaTypeImage:
|
||||
self.triggerPageAction(QWebEnginePage.CopyImageToClipboard)
|
||||
else:
|
||||
self.triggerPageAction(QWebEnginePage.Copy)
|
||||
|
||||
|
|
Loading…
Reference in a new issue