From 821b6a65aa7cef84c71f19c77d3ab3fc2b07a383 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 6 Apr 2018 16:46:09 +1000 Subject: [PATCH] Revert "work around issues writing to Windows clipboard" This reverts commit 25c3f2cb24fa4a748d01530da02b7aa6d7d45990. seemed to be causing crashes, and the underlying race condition wasn't solved --- aqt/editor.py | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/aqt/editor.py b/aqt/editor.py index dca91bd77..bdb1bc33c 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -21,7 +21,7 @@ from anki.hooks import runHook, runFilter from aqt.sound import getAudio from aqt.webview import AnkiWebView from aqt.utils import shortcut, showInfo, showWarning, getFile, \ - openHelp, tooltip, downArrow, showCritical + openHelp, tooltip, downArrow import aqt from bs4 import BeautifulSoup import requests @@ -909,36 +909,6 @@ class EditorWebView(AnkiWebView): return html = mime.html() mime.setHtml("" + html) - if isWin: - self._windowsSetMimeData(clip, mime) - else: - clip.setMimeData(mime) - - def _windowsSetMimeData(self, clip, mime): - import win32clipboard, time - from ctypes import windll - - grabbed = False - for i in range(10): - try: - win32clipboard.OpenClipboard(self.editor.parentWindow.winId()) - grabbed = True - break - except: - time.sleep(0.01) - continue - - if not grabbed: - hwnd = win32clipboard.GetOpenClipboardWindow() - - longpid = ctypes.c_ulong() - result = windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(longpid)) - pid = longpid.value - - showCritical(_("Unable to access clipboard - locked by process %d" % pid)) - return - - win32clipboard.CloseClipboard() clip.setMimeData(mime) def contextMenuEvent(self, evt):