KcoreAddons

David Faure faure at kde.org
Thu Oct 20 15:03:24 UTC 2011


(Sorry for the time it took me to answer, your Mail-Followup-To with two 
entries made kmail2 assert, so I had to fix that first :-)

On Sunday 16 October 2011 13:37:48 Oswald Buddenhagen wrote:
> On Sun, Oct 16, 2011 at 10:31:57AM +0200, David Faure wrote:
> > This makes sense, you don't really want -every- file being saved (e.g.
> > kconfig files, xmlgui files, bookmarks etc. etc.) to have 10 numbered
> > backups if the user enables that. This is usually only done for actual
> > documents.
> well, in my SaveFile class there is a bool property to enable (simple)
> backups. if the commit fails, it will rollback the backup, too.

Ah, this is an interesting idea.

> but one can get a nice api by inverting ownership: pass the SaveFile
> object to a KBackup::commitWithBackup() call. i'd still like to have
> QSaveFile::commitWithBackup() for simple backups, too.

You mean, in order to have other features in KBackup, but still offer simple 
backup there as well?

> another thing related to file saving: FileUtils::FileSaver. this
> drastically minimizes the write error checking boilerplate code and thus
> makes it at least somewhat likely that people will actually check for
> errors (correctly). however, i'm not entirely satisfied with the api -
> it looks messy. in particular, the setResult() functions should be in
> the various (stream) classes, which by extension need to provide
> FileSaver-aware api. but that would bloat the apis and make them
> confusing. so maybe filesaver should be just folded into qfile? how to
> activate that mode? setLatchErrors(bool)?

OK, found it in qtcreator's fileutils.cpp
I'll have to look further into it, but if the whole point is to "remember that 
there was an error while writing", can't QFile do that?
And then SaveFile can ask the QFile about it when finalizing.

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).



More information about the Kde-frameworks-devel mailing list