Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-27097

Intermittent clipboard mimedata copy failures on Windows

    XMLWordPrintable

    Details

    • Commits:
      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

        1. qtbug27097.diff
          3 kB
        2. qtbug27097.zip
          2 kB
        3. qtbug27097-v2.zip
          1 kB

          Issue Links

          For Gerrit Dashboard: QTBUG-27097
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              kleint Friedemann Kleint
              Reporter:
              kiwidude Grant Drake
              Votes:
              2 Vote for this issue
              Watchers:
              14 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes