Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.6.3, 6.7.0, 6.7.1, 6.7.2
-
None
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:
- Clone and build the repository
- Run the provided script, CreateLongPath.ps1, with a modern version of PowerShell.
- Navigate to the created long path in explorer.
- 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.