[Interest] Automatic deletion of children of QObject
Jochen Becher
jochen_becher at gmx.de
Tue Jun 12 20:37:02 CEST 2012
Hi,
Think of the following code:
QObject *parent = new QObject();
QObject *childA = new QObject(parent);
QObject *childB = new QObject)parent);
delete parent;
In which order would you expect childA and childB gets deleted? I would
expect childB first and childA second. This would be same behavior as in
using normal variables:
QObject parent;
QObject childA(&parent);
QObject childB(&parent);
Here, on leaving the scope childB would be deleted first, childA second
and parent last.
Isn't it a bug in Qt to delete children in the same order there were
added to a parent instead of the reverse order?
Regards, Jochen
More information about the Interest
mailing list