KcoreAddons

David Faure faure at kde.org
Fri Oct 21 09:22:42 UTC 2011


On Thursday 20 October 2011 20:00:58 Oswald Buddenhagen wrote:
> On Thu, Oct 20, 2011 at 05:03:24PM +0200, David Faure wrote:
> > On Sunday 16 October 2011 13:37:48 Oswald Buddenhagen wrote:
> > > 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?
> 
> yeah, that's the idea.
> it wouldn't make any sense if KBackup was in QtCore, but that seems a
> bit unlikely (it contains a bit too much esoteric functionality for my
> taste, and it relies on platform stuff).
> 
> > > 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?
> 
> that's what setLatchErrors() would be about. ;)
> it would also change some other behavior - e.g., a truncated write needs
> to be recorded as an error, too.
> 
> > And then SaveFile can ask the QFile about it when finalizing.
> 
> that's the idea :)

Oh, excellent. I hadn't noticed your last two lines were actually suggesting 
something different from the rest of your paragraph (and from the current 
qtcreator) code, so I came up with the same suggestion independently :-)

That must be a sign, I would say :)

Yes, truncated writes were exactly what I was thinking about, and the whole 
reason for putting this into QFile. I'm not really sure I understand the 
setLatchErrors() API idea though. Can't QFile "remember that there was an 
error" in all cases, and QSaveFile asks it, and other users might not, end of 
story? What's the setter for?

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