mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Revert "work around issues writing to Windows clipboard"
This reverts commit 25c3f2cb24
.
seemed to be causing crashes, and the underlying race condition wasn't solved
This commit is contained in:
parent
c01ba49168
commit
821b6a65aa
1 changed files with 1 additions and 31 deletions
|
@ -21,7 +21,7 @@ from anki.hooks import runHook, runFilter
|
||||||
from aqt.sound import getAudio
|
from aqt.sound import getAudio
|
||||||
from aqt.webview import AnkiWebView
|
from aqt.webview import AnkiWebView
|
||||||
from aqt.utils import shortcut, showInfo, showWarning, getFile, \
|
from aqt.utils import shortcut, showInfo, showWarning, getFile, \
|
||||||
openHelp, tooltip, downArrow, showCritical
|
openHelp, tooltip, downArrow
|
||||||
import aqt
|
import aqt
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import requests
|
import requests
|
||||||
|
@ -909,36 +909,6 @@ class EditorWebView(AnkiWebView):
|
||||||
return
|
return
|
||||||
html = mime.html()
|
html = mime.html()
|
||||||
mime.setHtml("<!--anki-->" + html)
|
mime.setHtml("<!--anki-->" + 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)
|
clip.setMimeData(mime)
|
||||||
|
|
||||||
def contextMenuEvent(self, evt):
|
def contextMenuEvent(self, evt):
|
||||||
|
|
Loading…
Reference in a new issue