[clazy] [Bug 403201] New: Detect passing the wrong parent for members

kpopv bugzilla_noreply at kde.org
Mon Jan 14 08:20:49 GMT 2019


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-bugs at kde.org
          Reporter: koen.poppe at vandewiele.com
                CC: smartins at 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 the assignee for the bug.


More information about the Unassigned-bugs mailing list