summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2017-05-10 10:18:04 (GMT)
committerfvogel <fvogelnew1@free.fr>2017-05-10 10:18:04 (GMT)
commit35ee785bcf312f1eb0bbcdf5822b0cce7c3907f2 (patch)
tree2df8f3963e705d28b2ed0f080674796ddd8506f1
parentbb805f74b6239a7dfb381e2df229fc05b9dce46d (diff)
parent45579f0759ba1e425bc28acb698f1649c6552166 (diff)
downloadtk-35ee785bcf312f1eb0bbcdf5822b0cce7c3907f2.zip
tk-35ee785bcf312f1eb0bbcdf5822b0cce7c3907f2.tar.gz
tk-35ee785bcf312f1eb0bbcdf5822b0cce7c3907f2.tar.bz2
Fix [a5ba1c9764]: Race condition in clipboard cleanup on Windows. Patch from Roman Donchenko
-rw-r--r--win/tkWinX.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/win/tkWinX.c b/win/tkWinX.c
index d41b6c1..6293ce7 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -676,19 +676,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,
@@ -865,6 +852,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: