From d448bd9cb6a8ac43baf5807f614b5066f179e557 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 11 Jun 2021 19:58:20 +1000 Subject: [PATCH] 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 --- qt/aqt/webview.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index 34fb57fc2..6b01df6d9 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -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)