On quinta-feira, 24 de maio de 2012 16.33.53, Olivier Goffart wrote: > > I've long wanted to make QSharedPointer on QObject-derivatives participate > > in the whole-tree ownership, somehow. I introduced QSharedPointer in 4.4 > > and I did some work in 4.5 to make that work. > > > > My original solution was to have a parent only deref its children's shared > > pointer counter, deleting it only if it became zero. That means that if > > you > > had a QSharedPointer to an object in the middle of the hierarchy, that > > object would be orphaned instead of deleted when the parent died. The > > converse was that when the last QSharedPointer reference to a QObject went > > away, the object might survive if it still had a parent. > > So that would be like having "children" be in implemented as a > QList<QSharedPointer<QObject> > ?
Yes, like that, but not actually implemented with that. > But I personaly think it shoud not be the case. QSharedPointer is > orthogonal with object tree as much as it is orthogonal with > std::shared_ptr or QScopedPointer or manually delete. > > You have to pick how you do thememory management for a given pointer and > stick to it. It is orthogonal and right now it's working orthogonally. This was just something I experimented with, but didn't work as intended. It crashed QWidget left and right. -- 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 Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development