From a5d97c02f0cdeadb55a582de9699f756d4b9ea4a Mon Sep 17 00:00:00 2001
From: Lawrence Rust <lvr@softsystem.co.uk>
Date: Tue, 5 Jun 2012 20:01:01 +0200
Subject: [PATCH] libmythui: Prevent memory leak of MythUIType children
Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
---
mythtv/libs/libmythui/mythuibuttonlist.cpp | 4 +---
mythtv/libs/libmythui/mythuitype.cpp | 16 ++++++----------
mythtv/libs/libmythui/mythuitype.h | 2 ++
3 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/mythtv/libs/libmythui/mythuibuttonlist.cpp b/mythtv/libs/libmythui/mythuibuttonlist.cpp
index 260095a..920a452 100644
a
|
b
|
void MythUIButtonList::CopyFrom(MythUIType *base) |
2780 | 2780 | |
2781 | 2781 | for (int i = 0; i < (int)m_itemsVisible; i++) |
2782 | 2782 | { |
2783 | | MythUIType *deltype; |
2784 | 2783 | QString name = QString("buttonlist button %1").arg(i); |
2785 | | deltype = GetChild(name); |
2786 | | delete deltype; |
| 2784 | DeleteChild(name); |
2787 | 2785 | } |
2788 | 2786 | |
2789 | 2787 | m_ButtonList.clear(); |
diff --git a/mythtv/libs/libmythui/mythuitype.cpp b/mythtv/libs/libmythui/mythuitype.cpp
index 5341e4b..5cd32b2 100644
a
|
b
|
MythUIType::MythUIType(QObject *parent, const QString &name) |
50 | 50 | m_IsDependDefault = false; |
51 | 51 | m_ReverseDepend = false; |
52 | 52 | |
53 | | m_Parent = NULL; |
54 | | |
55 | | if (parent) |
56 | | { |
57 | | m_Parent = dynamic_cast<MythUIType *>(parent); |
58 | | |
59 | | if (m_Parent) |
60 | | m_Parent->AddChild(this); |
61 | | } |
| 53 | // NB C++ 0X 5.2.7.4: cast of null = null |
| 54 | m_Parent = dynamic_cast<MythUIType * >(parent); |
| 55 | if (m_Parent) |
| 56 | m_Parent->AddChild(this); |
62 | 57 | |
63 | 58 | m_DirtyRegion = QRegion(QRect(0, 0, 0, 0)); |
64 | 59 | |
… |
… |
MythUIType::MythUIType(QObject *parent, const QString &name) |
71 | 66 | |
72 | 67 | MythUIType::~MythUIType() |
73 | 68 | { |
| 69 | DeleteAllChildren(); |
74 | 70 | delete m_Fonts; |
75 | 71 | qDeleteAll(m_animations); |
76 | 72 | } |
… |
… |
void MythUIType::ConnectDependants(bool recurse) |
1406 | 1402 | (*it)->ConnectDependants(recurse); |
1407 | 1403 | } |
1408 | 1404 | } |
1409 | | } |
1410 | | No newline at end of file |
| 1405 | } |
diff --git a/mythtv/libs/libmythui/mythuitype.h b/mythtv/libs/libmythui/mythuitype.h
index bbb0b09..4969c03 100644
a
|
b
|
class MUI_PUBLIC MythUIType : public QObject, public XMLParseBase |
67 | 67 | |
68 | 68 | public: |
69 | 69 | MythUIType(QObject *parent, const QString &name); |
| 70 | protected: |
70 | 71 | virtual ~MythUIType(); |
71 | 72 | |
| 73 | public: |
72 | 74 | virtual void Reset(void); |
73 | 75 | |
74 | 76 | void AddChild(MythUIType *child); |