QUrl behavior and KIO

David Faure faure at kde.org
Thu Sep 5 08:13:36 UTC 2013


On Wednesday 04 September 2013 18:39:57 Marco Martin wrote:
> Hi all,
> porting a couple of kio slaves (trying to make sense of the trash kio partly
> ported to kf5 in a gsoc) i noticed what appears to be a slight behavior
> change compared to when it used KUrl
> 
> something like this in kde4 was working:
> KUrl u;
> u.setPath( "/some/valid/path" );
> KIO::Job* job = KIO::move( u, KUrl("trash:/"), KIO::HideProgressInfo );
> 
> something like this doesn't:
> QUrl u;
> u.setPath( "/some/valid/path" );

Yep, this isn't a local file.
You have to be very careful when porting from KUrl to QUrl.
I'll document this particular trap better, I see it's not clearly documented.
This should be QUrl u = QUrl::fromLocalFile("/some/local/unix/path");

> QUrl u = QUrl::fromLocalFile( "/some/valid/path" );

See, you even knew that ;)

> what should be done? modify kio to make qurls without scheme work (and
> assume they are file://) or modify all the users to make sure a scheme is
> always passed?

Correct porting to QUrl is the only thing that makes sense IMHO.
Let's not start adding hacks for badly ported code.

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5



More information about the Kde-frameworks-devel mailing list