https://bugs.kde.org/show_bug.cgi?id=403201
Bug ID: 403201 Summary: Detect passing the wrong parent for members Product: clazy Version: unspecified Platform: Other OS: Linux Status: REPORTED Severity: wishlist Priority: NOR Component: general Assignee: unassigned-b...@kde.org Reporter: koen.po...@vandewiele.com CC: smart...@kde.org Target Milestone: --- Created attachment 117455 --> https://bugs.kde.org/attachment.cgi?id=117455&action=edit Minimal example SUMMARY QObject members can be constructed with this as parent so that they get cleaned up as part of the memory management of QObject trees. On construction of a QObject derived class, the passed in parent should be passed on to the superclass while this should be used as parent of all QObject derived members. It is not uncommon to see parent passed incorrectly to members, it would be nice if clazy could detect this. STEPS TO REPRODUCE 1. Open the attached project and run it. It is expected to crash. OBSERVED RESULT 1. m_c is destructed before m_b because m_c's parent is set incorrectly to a instead of b (during construction of b). This causes ~B to call a method on an already destroyed m_c, thus crashing the application. EXPECTED RESULT 1. m_c(new C(this)) instead of m_c(new C(parent)) SOFTWARE/OS VERSIONS Windows: 7 Qt Version: 5.9 -- You are receiving this mail because: You are watching all bug changes.