On 13.06.2012 23:35, Jan Kundrát wrote:
> On 06/13/12 22:50, Jochen Becher wrote:
>> Of course it is not a bad idea to access siblings in a destructor. Why
>> should it? If destruction follows in a known and reliable way there is
>> no reason to avoid it. I do it to check some post-conditions using
>> Q_ASSERT() to ensure all resources were freed and that involves some
>> checks in siblings.
> QObject's children are destroyed in an order which is not specified,
> hence it's a bad idea to access "siblings" in a QObject's destructor.

As far as I understand it, it is actually save to access child objects
inside the destructor. The childs get deleted in QObjects destructor
which is called after the destructors of the derived classes. In fact I
often did delete the childs in my own loop as that one was protected by
the mutex other objects used while adding or deleting childs of this
object. Relying on QObjects destructor was in that situation open for
race-conditions.

Have fun,

Arnold
-- 
Dieses Email wurde elektronisch erstellt und ist ohne handschriftliche
Unterschrift gültig.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to