Opened 13 years ago
Closed 13 years ago
#10807 closed Patch - Bug Fix (Invalid)
[PATCH] libmythui: Prevent memory leak and dangling reference to MythUIType children
Reported by: | Owned by: | stuartm | |
---|---|---|---|
Priority: | minor | Milestone: | unknown |
Component: | MythTV - General | Version: | Master Head |
Severity: | medium | Keywords: | MythUIType memory leak |
Cc: | Ticket locked: | no |
Description
Although ownership of all MythUIType objects is transferred to the parent during construction, the MythUIType destructor doesn't delete its children, resulting in a memory leak found by valgrind.
Also, because of the ownership semantics, MythUIType's dtor should be protected. This uncovers a bug in MythUIButtonList::CopyFrom? which should use the base DeleteChild? (rather than a direct delete) otherwise a dangling reference is left.
This bug and patch apply to git master, fixes/0.25 and fixes/0.24 (maybe more).
P.S. IMHO the base class XMLParseBase of MythUIType should be protected otherwise it defeats abstraction.
Attachments (1)
Change History (7)
Changed 13 years ago by
Attachment: | 0001-libmythui-Prevent-memory-leak-of-MythUIType-children.patch added |
---|
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
==9163== 96 bytes in 6 blocks are possibly lost in loss record 1,446 of 2,430 ==9163== at 0x4026864: malloc (vg_replace_malloc.c:236) ==9163== by 0x7B6765C: qMalloc(unsigned int) (qmalloc.cpp:55) ==9163== by 0x7B99611: QMapData::node_create(QMapData::Node**, int, int) (qmap.cpp:140) ==9163== by 0x5857220: QMap<int, MythUIType*>::node_create(QMapData*, QMapData::Node**, int const&, MythUIType* const&) (qmap.h:449) ==9163== by 0x586E1B8: QMap<int, MythUIType*>::operator[](int const&) (qmap.h:530) ==9163== by 0x586CD9D: MythUIStateType::AddObject(MythUIStateType::StateType, MythUIType*) (mythuistatetype.cpp:78) ==9163== by 0x586DCAC: MythUIStateType::CopyFrom(MythUIType*) (mythuistatetype.cpp:286) ==9163== by 0x586DDC1: MythUIStateType::CreateCopy(MythUIType*) (mythuistatetype.cpp:294) ==9163== by 0x5855252: MythUIType::CopyFrom(MythUIType*) (mythuitype.cpp:838) ==9163== by 0x589ED4C: MythUIGroup::CopyFrom(MythUIType*) (mythuigroup.cpp:24) ==9163== by 0x5835D38: XMLParseBase::ParseUIType(QString const&, QDomElement&, QString const&, MythUIType*, MythScreenType*, bool) (xmlparsebase.cpp:499) ==9163== by 0x586D7E1: MythUIStateType::ParseElement(QString const&, QDomElement&, bool) (mythuistatetype.cpp:229) ==9163== ==9163== 96 bytes in 6 blocks are possibly lost in loss record 1,447 of 2,430 ==9163== at 0x4026864: malloc (vg_replace_malloc.c:236) ==9163== by 0x7B6765C: qMalloc(unsigned int) (qmalloc.cpp:55) ==9163== by 0x7B99611: QMapData::node_create(QMapData::Node**, int, int) (qmap.cpp:140) ==9163== by 0x586E6D5: QMap<QString, MythUIType*>::node_create(QMapData*, QMapData::Node**, QString const&, MythUIType* const&) (qmap.h:449) ==9163== by 0x586E0F8: QMap<QString, MythUIType*>::operator[](QString const&) (qmap.h:530) ==9163== by 0x586C9A9: MythUIStateType::AddObject(QString const&, MythUIType*) (mythuistatetype.cpp:46) ==9163== by 0x586DBAF: MythUIStateType::CopyFrom(MythUIType*) (mythuistatetype.cpp:275) ==9163== by 0x586DDC1: MythUIStateType::CreateCopy(MythUIType*) (mythuistatetype.cpp:294) ==9163== by 0x5855252: MythUIType::CopyFrom(MythUIType*) (mythuitype.cpp:838) ==9163== by 0x58973FD: MythUIButtonList::CopyFrom(MythUIType*) (mythuibuttonlist.cpp:2431) ==9163== by 0x588A816: MythUISpinBox::CopyFrom(MythUIType*) (mythuispinbox.cpp:160) ==9163== by 0x5835D38: XMLParseBase::ParseUIType(QString const&, QDomElement&, QString const&, MythUIType*, MythScreenType*, bool) (xmlparsebase.cpp:499)
comment:5 Changed 13 years ago by
Owner: | set to stuartm |
---|---|
Status: | new → assigned |
comment:6 Changed 13 years ago by
Resolution: | → Invalid |
---|---|
Status: | assigned → closed |
Children of a QObject are deleted by the QObject destructor thus shouldn't be leaking.