Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.12.9, 5.13.1, 5.15.0
-
None
-
Tested under Windows with Qt 5.12, 5.13 and 5.15, both can reproduce this issue. Let me know if you need any additional info.
-
-
97de53ee8cce3dc6347b08668f0de45e1000f01c 9ef4fba108761bf30b9572fc53eaf98008bb4aae (qt/qtbase/5.15)
Description
When using WSL2 (Windows Subsystem for Linux 2), the file system can be accessed from such path like \\wsl$\Ubuntu\home\username\filename.png , but when trying to use QUrl to store that path, it will not store the hostname ("wsl$") properly.
QString filePath(R"(\\wsl$\Ubuntu\home\username\filename.png)"); QString filePath2(R"(\\wsl\Ubuntu\home\username\filename.png)"); // according to the documentation of QUrl::fromLocalFile(): // ... also accepts paths with a doubled leading slash (or backslash) to indicate a remote file, as in "//servername/path/to/file.txt" ... QUrl url1 = QUrl::fromLocalFile(filePath); QUrl url2 = QUrl::fromUserInput(filePath); QUrl url3 = QUrl::fromLocalFile(filePath2); qDebug() << url1 << url2 << url3 << url1.host() << url3.host(); // will print: QUrl("file:///Ubuntu/home/username/filename.png") QUrl("file:///Ubuntu/home/username/filename.png") QUrl("file://wsl/Ubuntu/home/username/filename.png") "" "wsl"
After a quick look at the implementation of QUrl::fromLocalFile(), I found out when calling QUrl::setHost() with "wsl$", it will not set "wsl$" as the hostname, which caused this issue. I haven't dig-in to much so still don't know what's the root of this issue.
Let me know if you need any additional info for this issue.
ps. I did submit this issue as QTBUG-86275 earlier today but I cannot find it anymore but it seems that bug is a completely different bug now, don't know why..
Attachments
Issue Links
- relates to
-
QTBUG-88599 QFileSelector returns empty path
- Closed
- replaces
-
QTBUG-86321 urls in QDropEvent is not correct when drag and drop file from WSL2 network location to Qt widget
- Closed