diff options
author | fvogel <fvogelnew1@free.fr> | 2017-05-05 21:25:29 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2017-05-05 21:25:29 (GMT) |
commit | 18da6f580a2bb9daa22123c2ff6aaa6bd6609005 (patch) | |
tree | ba07f751e216da994b6e2330651eed2c384d76b7 /win | |
parent | f19be0447c6d2d01a10d3881d6f8aab3c87dad5d (diff) | |
download | tk-18da6f580a2bb9daa22123c2ff6aaa6bd6609005.zip tk-18da6f580a2bb9daa22123c2ff6aaa6bd6609005.tar.gz tk-18da6f580a2bb9daa22123c2ff6aaa6bd6609005.tar.bz2 |
Fix [a5ba1c9764]: Race condition in clipboard cleanup on Windows. Patch from Roman Donchenko (aka dpb).bug_a5ba1c9764
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinX.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/win/tkWinX.c b/win/tkWinX.c index 098fc6d..fca72c3 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -686,19 +686,6 @@ TkClipCleanup( TkDisplay *dispPtr) /* Display associated with clipboard. */ { if (dispPtr->clipWindow != NULL) { - /* - * Force the clipboard to be rendered if we are the clipboard owner. - */ - - HWND hwnd = Tk_GetHWND(Tk_WindowId(dispPtr->clipWindow)); - - if (GetClipboardOwner() == hwnd) { - OpenClipboard(hwnd); - EmptyClipboard(); - TkWinClipboardRender(dispPtr, CF_TEXT); - CloseClipboard(); - } - Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, dispPtr->applicationAtom); Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, @@ -875,6 +862,23 @@ Tk_TranslateWinEvent( return 1; } + case WM_RENDERALLFORMATS: { + TkWindow *winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd); + + if (winPtr && OpenClipboard(hwnd)) { + /* + * Make sure that nobody had taken ownership of the clipboard + * before we opened it. + */ + + if (GetClipboardOwner() == hwnd) { + TkWinClipboardRender(winPtr->dispPtr, CF_TEXT); + } + CloseClipboard(); + } + return 1; + } + case WM_COMMAND: case WM_NOTIFY: case WM_VSCROLL: |