Ticket #10807: 0001-libmythui-Prevent-memory-leak-of-MythUIType-children.patch

File 0001-libmythui-Prevent-memory-leak-of-MythUIType-children.patch, 2.6 KB (added by Lawrence Rust <lvr@…>, 8 years ago)
  • mythtv/libs/libmythui/mythuibuttonlist.cpp

    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) 
    27802780
    27812781    for (int i = 0; i < (int)m_itemsVisible; i++)
    27822782    {
    2783         MythUIType *deltype;
    27842783        QString name = QString("buttonlist button %1").arg(i);
    2785         deltype = GetChild(name);
    2786         delete deltype;
     2784        DeleteChild(name);
    27872785    }
    27882786
    27892787    m_ButtonList.clear();
  • mythtv/libs/libmythui/mythuitype.cpp

    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) 
    5050    m_IsDependDefault = false;
    5151    m_ReverseDepend = false;
    5252
    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);
    6257
    6358    m_DirtyRegion = QRegion(QRect(0, 0, 0, 0));
    6459
    MythUIType::MythUIType(QObject *parent, const QString &name) 
    7166
    7267MythUIType::~MythUIType()
    7368{
     69    DeleteAllChildren();
    7470    delete m_Fonts;
    7571    qDeleteAll(m_animations);
    7672}
    void MythUIType::ConnectDependants(bool recurse) 
    14061402                (*it)->ConnectDependants(recurse);
    14071403        }
    14081404    }
    1409 }
    1410  No newline at end of file
     1405}
  • mythtv/libs/libmythui/mythuitype.h

    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 
    6767
    6868  public:
    6969    MythUIType(QObject *parent, const QString &name);
     70  protected:
    7071    virtual ~MythUIType();
    7172
     73  public:
    7274    virtual void Reset(void);
    7375
    7476    void AddChild(MythUIType *child);