Qt 4.8 QUrl.toLocalFile behavior change, impacts to KUrl (and friends)

Kevin Kofler kevin.kofler at chello.at
Sun Oct 30 18:02:48 GMT 2011


Kevin Kofler wrote:
> No, it doesn't.
> 
> There's actually a difference between KUrl(str):
> https://projects.kde.org/projects/kde/kdelibs/repository/entry/kdecore/io/kurl.cpp?rev=KDE%2F4.7#L400
> and KUrl::fromPathToUrl(str):
> https://projects.kde.org/projects/kde/kdelibs/repository/entry/kdecore/io/kurl.cpp?rev=KDE%2F4.7#L1669
> and it affects relative paths. KUrl(str) will treat a relative path as a
> URL, KUrl::fromPathToUrl(str) will treat it as a path! Both treat absolute
> paths as paths and URLs with scheme as URLs.

Oops, I misread the code!

They both do the same thing after all, fromPathToUrl explicitly does NOT
treat relative paths as paths.

But that doesn't change much of the rest of my message: we definitely do
need an API which treats relative paths as file paths (for most
applications) and an API which treats relative paths as relative URLs (for
web browsers and such).

I think there should be 3 ways to construct a URL:
1. from a path (always), i.e. the current KUrl::fromPath
2. heuristically (replacing the current KUrl::KUrl and KUrl::fromPathToUrl):
   * absolute paths should be file paths
   * relative paths should be file paths (!) (currently, they're URLs)
   * everything with a URL scheme (protocol) should be a URL
3. from a URL (always) – web browsers or any other app where the relative
   context is a URL context should use this instead of 2.

        Kevin Kofler





More information about the kde-core-devel mailing list