From kde-commits Mon Nov 15 05:19:20 2010 From: Jonathan Michael Thomas Date: Mon, 15 Nov 2010 05:19:20 +0000 To: kde-commits Subject: extragear/sysadmin/muon/installer Message-Id: <20101115051920.E3A70AC8A0 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=128979840012356 SVN commit 1197231 by jmthomas: Optimize: The Category class doesn't really need any QObject features since it is mainly a control structure surrounding a chunk of an XML file. Also fix a memory leak in populateCategories() where the list would be re-populated without deleting the Category objects when called the second time M +2 -1 AvailableView.cpp M +6 -4 CategoryView/Category.cpp M +4 -5 CategoryView/Category.h --- trunk/extragear/sysadmin/muon/installer/AvailableView.cpp #1197230:1197231 @@ -77,6 +77,7 @@ void AvailableView::populateCategories() { + qDeleteAll(m_categoryList); QFile menuFile(KStandardDirs::locate("appdata", "categories.xml")); if (!menuFile.open(QIODevice::ReadOnly)) { @@ -94,7 +95,7 @@ QDomNode node = root.firstChild(); while(!node.isNull()) { - Category *category = new Category(this, node); + Category *category = new Category(node); m_categoryList << category; node = node.nextSibling(); --- trunk/extragear/sysadmin/muon/installer/CategoryView/Category.cpp #1197230:1197231 @@ -20,9 +20,10 @@ #include "Category.h" -Category::Category(QObject *parent, const QDomNode &data) - : QObject(parent) - , m_iconString("applications-other") +#include + +Category::Category(const QDomNode &data) + : m_iconString("applications-other") , m_hasSubCategories(false) { parseData(data); @@ -30,6 +31,7 @@ Category::~Category() { + qDeleteAll(m_subCategories); } void Category::parseData(const QDomNode &data) @@ -51,7 +53,7 @@ m_iconString = tempElement.text(); } } else if (tempElement.tagName() == QLatin1String("Menu")) { - Category *subCategory = new Category(this, node); + Category *subCategory = new Category(node); m_subCategories << subCategory; m_hasSubCategories = true; } else if (tempElement.tagName() == QLatin1String("Include")) { --- trunk/extragear/sysadmin/muon/installer/CategoryView/Category.h #1197230:1197231 @@ -22,11 +22,11 @@ #define CATEGORY_H #include -#include #include #include -#include +class QDomNode; + enum FilterType { InvalidFilter = 0, CategoryFilter = 1, @@ -35,11 +35,10 @@ PkgNameFilter = 4 }; -class Category : public QObject +class Category { - Q_OBJECT public: - explicit Category(QObject *parent, const QDomNode &node); + explicit Category(const QDomNode &node); ~Category(); QString name() const;