https://bugs.documentfoundation.org/show_bug.cgi?id=116983
--- Comment #81 from jasonkres <ja...@binarycoder.net> ---
Created attachment 169641
--> https://bugs.documentfoundation.org/attachment.cgi?id=169641&action=edit
ClipboardTest.cpp code that provokes the problem
This is happening because only one application can be within
OpenClipboard/CloseClipboard at the same time. LO calls OleGetClipboard which
uses OpenClipboard/CloseClipboard internally. Per
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-openclipboard
"OpenClipboard fails if another window has the clipboard open." This can
probably happen easily as various applications receiving the WM_CLIPBOARDUPDATE
notification each try to examine the clipboard simultaneously.
This seems to explain why Ctrl+V usually works even when the toolbar/context
menu is grayed out. It possibly explains why there are times, although
infrequently, when even Ctrl+V does not work.
For an example of a workaround implemented by Microsoft, see this code which
synchronously retries 10 times with a delay of 100 ms between each attempt.
(See
https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms/src/System/Windows/Forms/Clipboard.cs)
Note that reading the clipboard is not the only susceptible operation; others
that LO calls (OleSetClipboard, OleFlushClipboard) can fail too. This
coincidental timing sounds less likely, but apparently there are apps that can
provoke errors on setting the clipboard too. Sounds like one of them is
Windows's Remote Desktop clipboard support, so those may be important to fix as
well. Some of the references given below cover this.
* Doesn't happen on your system (using my repro procedure from comment 78)?
Use the attached ClipboardTest.cpp program. It contains a Sleep(500) during
OpenClipboard/CloseClipboard which should be more than enough to provoke the
problem. The problem often happens for me even with this sleep is omitted.
* Happens on your system?
If you use the attached program with the Sleep(500) commented out, it will
often print the hwnd of the program causing the problem on your system.
Info from others:
https://blog.somewhatabstract.com/2012/06/27/when-the-clipboard-says-no/
https://stackoverflow.com/questions/1859102/how-can-i-fix-cannot-open-clipboard-access-denied-errors
https://stackoverflow.com/questions/68666/clipbrd-e-cant-open-error-when-setting-the-clipboard-from-net
https://bugreports.qt.io/browse/QTBUG-27097
--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs