Created attachment 117455 [details] 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
Could make sense. If there's too many false-positives we can always disable it by default