https://bugs.kde.org/show_bug.cgi?id=382242
Bug ID: 382242 Summary: Deprecated hint for KUrl::path() is wrong on Windows Product: frameworks-kdelibs4support Version: 5.36.0 Platform: Other OS: Linux Status: UNCONFIRMED Severity: normal Priority: NOR Component: general Assignee: kdelibs-b...@kde.org Reporter: ralf.habac...@freenet.de Target Milestone: --- At https://api.kde.org/frameworks/kdelibs4support/html/classKUrl.html#a04479511596e499f4f7ffa6acdc96cb3 there is documentated Deprecated: since 5.0, use QUrl::path(). .... This advice results into code returning an invalid path on Windows in case QUrl contains a local path because QUrl::path() on Windows always adds a '/' in front of the path. The following example shows the issue QUrl b = QUrl::fromLocalFile("/test/test.xyz"); qDebug() << b << b.path() << b.toLocalFile(); b = QUrl::fromLocalFile("c:/test/test.xyz"); qDebug() << b << b.path() << b.toLocalFile(); b = QUrl::fromLocalFile("c:\\test\\test.xyz"); qDebug() << b << b.path() << b.toLocalFile() Compiling and running this on Windows (I used Qt 5.5) returns QUrl("file:///test/test.xyz") "/test/test.xyz" "/test/test.xyz" QUrl("file:///c:/test/test.xyz") "/c:/test/test.xyz" "c:/test/test.xyz" QUrl("file:///c:/test/test.xyz") "/c:/test/test.xyz" "c:/test/test.xyz" The second column in line 2 and 3 shows the issue. Because KUrl::path() deals with this case by checking the "local file case" and using toLocalFile() instead porting to QUrl::path() directly will fail therefore. Also the hint to use url.adjusted(QUrl::StripTrailingSlash).path() in case the option RemoveTrailingSlash has been used does not help here. There should be a related hint into the documentation. -- You are receiving this mail because: You are watching all bug changes.