diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 8cefd11d8..64c9d007e 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -1374,9 +1374,19 @@ class EditorWebView(AnkiWebView): mime = clip.mimeData() if not mime.hasHtml(): return - html = mime.html() - mime.setHtml(f"{html}") - aqt.mw.progress.timer(10, lambda: clip.setMimeData(mime), False, parent=self) + html = f"{mime.html()}" + + def after_delay() -> None: + # utilities that modify the clipboard can invalidate our existing + # mime handle in the time it takes for the timer to fire, so we need + # to fetch the data again + mime = clip.mimeData() + mime.setHtml(html) + clip.setMimeData(mime) + + # Mutter bugs out if the clipboard data is mutated in the clipboard change + # hook, so we need to do it after a small delay + aqt.mw.progress.timer(10, after_delay, False, parent=self) def contextMenuEvent(self, evt: QContextMenuEvent) -> None: m = QMenu(self)