On 10 January 2014 19:09, Frank Hemer <fr...@hemer.org> wrote: > On Friday 10 January 2014 21:58:13 Constantin Makshin wrote: >> No, it won't. 'this' is just a pointer and copying it anywhere (except a >> free-memory-in-destructor kind of smartpointer, of course, but using these >> to store a pointer to the parent object is a weird idea anyway) doesn't >> affect the object's lifetime in any way; neither does the object's >> destructor gets called when a pointer to it is destroyed by going out of >> scope or any other means. > > Well, I was confused by the QObject d'tor doc stating: > > Warning: All child objects are deleted. If any of these objects are on the > stack or global, sooner or later your program will crash. We do not recommend > holding pointers to child objects from outside the parent. If you still do, > the destroyed() signal gives you an opportunity to detect when an object is > destroyed. > > And the networkMgr is on the stack.
It's not "on the stack"; it's a member. This means it will be properly destroyed at the end of the QtSoapHttpTransport's destructor, which will run before QObject's destructor. The destruction code of QNAM (actually, of its QObject subobject) will remove it from the parent children list. So when the QObject destructor (for the QObject sub-object of QtSoapHttpTransport), it won't double delete anything. -- Giuseppe D'Angelo _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest