On Saturday, 7 de January de 2012 16.56.19, Stephen Kelly wrote: > On Friday, January 06, 2012 19:09:26 Thiago Macieira wrote: > > If the method accepted a QFile pointer before, then a class derived from > > QFile will automatically downcast to the type. > > This could be a downcast-vs-upcast definition mismatch in your > understandings?
Downcast = towards base class
Upcast = towards most derived
> I think David is saying that a method which takes a QFile* would have to
> qobject_cast<QSaveFile*>(file) to call its rollback method if it were a
> separate class.
Indeed. But it shouldn't need to do that. A method that takes an *open* file
should not try to close it. You have a method that creates a QSaveFile, opens
it, passes to another method. This second method should only write, not
attempt to open or close. It doesn't need to care what else there is. If there
was a failure in writing, it reports. Once it is done, the outer layer, which
still has a QSaveFile pointer or object, will do the committing and closing.
> Of course it's also common to have methods that do writing to take a
> QIODevice*. Does it make any sense to add a virtual rollback() to that
> (which obviously would do nothing in many overrides)?
No, I don't think so.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
Intel Sweden AB - Registration Number: 556189-6027
Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
