KUrl(QString) fix

Ralf Habacker ralf.habacker at freenet.de
Wed Dec 20 20:14:18 GMT 2006


Leonardo Stern schrieb:
>> May be a workaround on windows could be to call QUrl::toLocalFile()
>> instead of QUrl::path() in KUrl::path()
>>
>> Unfortunally KUrl::path() is an inline function. :-(
>>     
>
> But isn't this the same situation of the current solution (setPath
> ignores the leading "/" when QString begins with "file:///") ?
>   
Not at all. I have found non catched cases for example 
kio/tests/netaccesstest.exe .At least there are additional constructors 
which uses directly QUrl

KUrl::KUrl( const KUrl& _u )
    : QUrl( _u ), d(0)
{
}

KUrl::KUrl( const QUrl &u )
    : QUrl( u ), d(0)
{
}
There may be more places in KUrl. It looks if i have to dig more into 
this stuff.
> Maybe TT can modify QFile to ignore the leading "/" when succedeed by
> "[A-Za-z]:" as previously suggested in this list.
>   
I don't think that this is a good solution because on windows using /C:/ 
is not natural, a unix counterpart would be if someone would request to 
add for example an '!' prefix to pathes because of some technical 
limitations or misinterpretation of a given api. This would not be 
natural on linux also.

QUrl states clearly that path() does not return a local file path and 
that there are specific functions to convert local files into url's.

QString QUrl::toLocalFile () const
Returns the path of this URL formatted as a local file path.

QUrl QUrl::fromLocalFile ( const QString & localFile )  [static]
Returns a QUrl representation of localFile, interpreted as a local file.

QString QUrl::path () const
Returns the path of the URL.

Seems to be good to check the KUrl api how clean it deals with this 
difference and how this limitation could be removed.

Ralf





More information about the kde-core-devel mailing list