Merge pull request #7141 from radarhere/grabclipboardwin32

This commit is contained in:
Hugo van Kemenade 2023-06-06 09:24:13 +03:00 committed by GitHub
commit 3568df8af1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -436,10 +436,16 @@ PyImaging_GrabClipboardWin32(PyObject *self, PyObject *args) {
UINT formats[] = {CF_DIB, CF_DIBV5, CF_HDROP, RegisterClipboardFormatA("PNG"), 0}; UINT formats[] = {CF_DIB, CF_DIBV5, CF_HDROP, RegisterClipboardFormatA("PNG"), 0};
LPCSTR format_names[] = {"DIB", "DIB", "file", "png", NULL}; LPCSTR format_names[] = {"DIB", "DIB", "file", "png", NULL};
if (!OpenClipboard(NULL)) {
// Maybe the clipboard is temporarily in use by another process.
// Wait and try again
Sleep(500);
if (!OpenClipboard(NULL)) { if (!OpenClipboard(NULL)) {
PyErr_SetString(PyExc_OSError, "failed to open clipboard"); PyErr_SetString(PyExc_OSError, "failed to open clipboard");
return NULL; return NULL;
} }
}
// find best format as set by clipboard owner // find best format as set by clipboard owner
format = 0; format = 0;