From 1d2d6e51b96cc38963748f4d12ab4e17069e1e04 Mon Sep 17 00:00:00 2001 From: llama <100429699+iamllama@users.noreply.github.com> Date: Tue, 15 Apr 2025 18:26:18 +0800 Subject: [PATCH] Fix error when middle clicking in editor on systems w/o global mouse selection (#3923) * fix potential error when middle clicking in editor * update about.py --- qt/aqt/about.py | 1 + qt/aqt/editor.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qt/aqt/about.py b/qt/aqt/about.py index 25bb56a72..9a75c4491 100644 --- a/qt/aqt/about.py +++ b/qt/aqt/about.py @@ -219,6 +219,7 @@ def show(mw: aqt.AnkiQt) -> QDialog: "Brayan Oliveira", "Market345", "Yuki", + "🦙 (siid)", ) ) diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 6736adc42..988ba4676 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -1497,8 +1497,8 @@ class EditorWebView(AnkiWebView): def _get_clipboard_html_for_field(self, mode: QClipboard.Mode) -> str | None: clip = self._clipboard() - mime = clip.mimeData(mode) - assert mime is not None + if not (mime := clip.mimeData(mode)): + return None if not mime.hasHtml(): return None return mime.html() @@ -1540,9 +1540,9 @@ class EditorWebView(AnkiWebView): print("reuse internal") self.editor.doPaste(html, True, extended) else: + if not (mime := clipboard.mimeData(mode=mode)): + return print("use clipboard") - mime = clipboard.mimeData(mode=mode) - assert mime is not None html, internal = self._processMime(mime, extended) if html: self.editor.doPaste(html, internal, extended)