Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.7, 5.11.1
-
Reproduced on Windows 7 + Windows 10
-
ecfa33e751115919ddb47a6f641a2b1842c96788 (qtbase/5.12, 28.9.2018, 5.12.b1)
Description
Windows operations with the clipboard will intermittently fail (this is not just a Qt issue, but Qt fails to properly handle it). The copy operations will fail sporadically with an "Access is denied" error when trying to set mime data. Qt's clipboard logic handles this poorly - it just emits a qErrnoWarning message. So not only does the user does not have the selected text on the clipboard, if the application has wired in a Qt message handler to display error dialogs they get an unnecessary error dialog in their face, with the "QClipboard::setMimeData: Failed to set data on clipboard (Access is denied.)" message.
What Qt should do is put in place a retry loop to repeat the operation a few ms later, at which point from my own experimentation it inevitably will succeed. This is not a problem only Qt has, it is a known pattern for .NET applications to do similar.
The controls that are particularly prevalent with this issue I have found are the QWebPage and QPlainTextEdit. Unlike many intermittent issues it is absolutely trivial to replicate the issue (on a Windows system of course). Just create a QPlainTextEdit control, add create a loop with a singleShot timer that repeatedly calls the copy() function on it every few ms. Or do similar with a QWebPage triggering the Copy action. Out of every 500 or so attempts you will see a handful of clipboard copy failures.
Please fix this!!! We have tried workaround solutions that don't involve patching Qt ourselves to avoid custom builds. However it is a problem that can only conclusively be fixed without a load of filthy code by adding the retry within the QClipboard::setMimeData() function.
Attachments
Issue Links
- relates to
-
QTBUG-25318 Windows: Suggest to implement fallback for clipboard (text) should OleInitialize fail due to different COM thread apartment mode or similar
- Reported
For Gerrit Dashboard: QTBUG-27097 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
233795,3 | Windows QPA: Work around intermittent clipboard copy failures | 5.12 | qt/qtbase | Status: MERGED | +2 | 0 |