Big trouble with KIO::NetAccess::enter_loop()

David Faure faure at kde.org
Sun May 2 13:34:24 BST 2004


On Friday 30 April 2004 12:18, Michael Brade wrote:
> Any ideas?
Not really about the bug, but looking at the code, I see a wrong KURL usage and
a network-enabled method used for a local-file-only case.

    QString file = KGlobal::dirs()->saveLocation( "appdata" ) + "notes.ics";
    QString backup = file + "~";
    if ( KIO::NetAccess::exists( KURL( file ), true, 0 ) &&
         !KIO::NetAccess::file_copy( KURL( file ), KURL( backup ), -1, true ) )

Do NOT use KURL(file) when file is a path, this leads to encoding errors, you
should use KURL u; u.setPath(file);    or KURL::fromPathOrURL(file);

Anyway my suggestion for making a backup file (as long as this is only for local files) :
  KSaveFile::backupFile( file );

But in your case, I don't think you even need to call it. You're saving an ICS file,
and the backupFile call that I added to ICalFormat::save in libkcal, takes care of
creating a backup file already. So I suggest just removing the whole stuff from knotes.

Of course this doesn't help tracking the bug with NetAccess, if there is one,
but that remains to be proven. If you want to track it down - how many times are
the NetAccess methods called? Both backtraces point to file_copy, which is only called
from the above resourcelocal.cpp "make a backup file" code (apparently), but 
the question is whether save() is called once or twice (recursively?).
If it's called twice, there's no real NetAccess bug (it's not supposed to be 
called recursively), and in any case I'd be for just removing the code.

-- 
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