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

Drag-and-drop fails on Windows for files with paths longer than 260 characters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.6.3, 6.7.0, 6.7.1, 6.7.2
    • GUI: Drag and Drop
    • None
    • Windows

    Description

      On Windows, when attempting to drag-and-drop a file with a path exceeding 260 characters, the QMimeData::urls() function accessed via theĀ QDropEvent returns an empty list, even though QMimeData::hasUrls() returns true. No error message or explanation is provided for this behavior.

      Debugging reveals that the IDataObject::GetData call in getData in qwindowsmimeregistry.cpp fails with ERROR_INSUFFICIENT_BUFFER. This is, of course, in spite of the fact that that function doesn't provide a buffer, which would imply that this is a problem internal to COM. I could be misunderstanding the matter though.

      This remains a Qt bug in part because of the anomalous behavior of hasUrls and in part because it can be worked around. The full file paths are available for retrieval via a Shell IDList Array. I've provided a sample program that demonstrates both the above bug and the proposed solution.

      It is embarrassing how long this took me to work out. The affected versions listed are only those I've tested; it could be all versions.

      Reproduction instructions:

      1. Clone and build the repository
      2. Run the provided script, CreateLongPath.ps1, with a modern version of PowerShell.
      3. Navigate to the created long path in explorer.
      4. Run the program and drag a simple short path onto the main window. It should indicate no issues. Drag the files created in the long path onto the window and note the difference. The paths should be resolved, but only by the method I've provided.

      https://github.com/roflcopter4/BugReproduction01

      EDIT: I've attached a build of the above project. And touched it up a bit.

      Attachments

        1. BugReproduction01.7z
          9.08 MB
          Brendan Leason
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            roflcopter4 Brendan Leason
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes