[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Qt 4.8 QUrl.toLocalFile behavior change,
From:       Thiago Macieira <thiago () kde ! org>
Date:       2011-10-29 7:25:03
Message-ID: 2906091.yU3oNfbFMX () doriath
[Download RAW message or body]


On Saturday, 29 de October de 2011 04:38:00 Milian Wolff wrote:
> 1) When does it manifest? Apparently when using QUrl("...") directly, if I'm
> not mistaken. But what if we use KUrl?

You're correct: this problem manifests when you use QUrl's constructor 
directly, assuming it will understand a local file path for what it is and not 
parse it is a URL. KUrl's constructor calls fromPathOrUrl, so it will try to 
guess according to some heuristics.

The reason why this behaviour exists in QUrl and why I think KUrl is flawed is 
that there's a category of URLs that are incomplete, the relative URLs, also 
known as URL refs. That's what you see in the "href" or "src" attributes in 
HTML: those are real URL components, but they are partial. They need to be 
resolved against a base URL, usually the document's. 

There's no way to tell apart a local file path from a URL ref and the examples 
I gave show how it would be interpreted differently.

> 2) Is the -D... define to catch this problem at compile time already
> supported  in Qt 4.7?

Yes.

Note it just makes the constructor explicit: it's meant to catch accidental 
conversions. If you spell out QUrl, it will still get used.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic