[PATCH] KParts::ReadWritePart::saveAs - part 3

David Faure faure at kde.org
Wed Mar 10 16:07:42 GMT 2004


On Wednesday 10 March 2004 16:21, Andras Mantia wrote:
> In order to complete my work on the KParts, here is another patch, which makes
> the url restoring on save failure working also in case of saving to remote
> files. The patch is not so trivial as it seems (care must be taken where we
> update the m_originalURL to the current m_url), so please review it.
> My only concern is what if openURL is reimplemented, so d->m_originalURL
> remains empty and if save fails, the m_url will become empty.
>   I've tried this with the Kate part where I see that openURL is reimplemented
> and it worked fine, still I'm cautious. 
I guess it fails if for some reason save() fails - saving to initial url, not "save as".
E.g. if you remove permissions on the file while it's open.
Then m_url will be set to empty because originalURL is empty.

m_url being protected hits us here, parts can set it without calling openURL,
so we have nowhere to hook the "copy into originalURL" code.

> Another solution might be to make a 
> difference in saveToURL and slotUploadFinished and restore the m_url on error
> only if the saveToURL was called due to a saveAs call.

Yes, all this would be simpler if the new code was only activated for 'save as'.
It would also allow us to keep the new var empty the rest of the time, saving some mem :)

That would mean a new bool "d->m_duringSaveAs" or so (in the bitfield -> won't take any mem),
using d->m_originalURL only in saveAs and the slots connected to it, and ensuring that bool
is false all the time except during save as (simpler is to set to false again at the end of
a save as, successful or not).

Thanks.

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