Patch for kdelibs/kabc/plugins/file/

David Faure faure at kde.org
Mon Mar 20 09:23:03 GMT 2006


On Friday 17 March 2006 10:07, Tom Albers wrote:
> +          dest.setPath( mFileName );
> +          
> +          KIO::DeleteJob* job = KIO::del( dest, false, false ); 
> +          KIO::NetAccess::synchronousRun( job, 0);

QFile::remove( mFileName ) would probably be much faster; this code doesn't
need network transparency.

For rename you can use ::rename().
For copying it's a bit more tricky; KSaveFile has some code for that internally,
but I see no public API... time to make one or copy that code for now.

The problem with using KIO (even with NetAccess) is that it opens an event loop
there, so timers will run and paint events will happen, possibly leading to unexpected 
re-entrancy in this code. It's ok in high-level code, but not inside a kabc resource; we 
had similar bugs with the kolab resource iirc (due to korganizer using the addressbook
in a paint event, and it was still loading so it would request for it to be loaded again,
every time... That particular one is fixed now, but in any case I fear that opening an
event loop there might be dangerous).

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).





More information about the kde-core-devel mailing list