Skip to content

If the clipboard fails to open on Windows, wait and try again#7141

Merged
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:grabclipboardwin32
Jun 6, 2023
Merged

If the clipboard fails to open on Windows, wait and try again#7141
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:grabclipboardwin32

Conversation

@radarhere
Copy link
Member

Resolves #7133

The user is intermittently hitting

Pillow/src/display.c

Lines 439 to 440 in 2467db4

if (!OpenClipboard(NULL)) {
PyErr_SetString(PyExc_OSError, "failed to open clipboard");

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-openclipboard states

OpenClipboard fails if another window has the clipboard open.

If the error is hit, this PR pauses for 0.5s, and then tries again.

@siteng98
Copy link

I think this would work great!

@hugovk hugovk merged commit 3568df8 into python-pillow:main Jun 6, 2023
@radarhere radarhere deleted the grabclipboardwin32 branch June 6, 2023 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants