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
This commit is contained in:
llama 2025-04-15 18:26:18 +08:00 committed by GitHub
parent e7fbf159a6
commit 1d2d6e51b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View file

@ -219,6 +219,7 @@ def show(mw: aqt.AnkiQt) -> QDialog:
"Brayan Oliveira", "Brayan Oliveira",
"Market345", "Market345",
"Yuki", "Yuki",
"🦙 (siid)",
) )
) )

View file

@ -1497,8 +1497,8 @@ class EditorWebView(AnkiWebView):
def _get_clipboard_html_for_field(self, mode: QClipboard.Mode) -> str | None: def _get_clipboard_html_for_field(self, mode: QClipboard.Mode) -> str | None:
clip = self._clipboard() clip = self._clipboard()
mime = clip.mimeData(mode) if not (mime := clip.mimeData(mode)):
assert mime is not None return None
if not mime.hasHtml(): if not mime.hasHtml():
return None return None
return mime.html() return mime.html()
@ -1540,9 +1540,9 @@ class EditorWebView(AnkiWebView):
print("reuse internal") print("reuse internal")
self.editor.doPaste(html, True, extended) self.editor.doPaste(html, True, extended)
else: else:
if not (mime := clipboard.mimeData(mode=mode)):
return
print("use clipboard") print("use clipboard")
mime = clipboard.mimeData(mode=mode)
assert mime is not None
html, internal = self._processMime(mime, extended) html, internal = self._processMime(mime, extended)
if html: if html:
self.editor.doPaste(html, internal, extended) self.editor.doPaste(html, internal, extended)