[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/sysadmin/muon/installer
From:       Jonathan Michael Thomas <echidnaman () kubuntu ! org>
Date:       2010-11-15 5:19:20
Message-ID: 20101115051920.E3A70AC8A0 () svn ! kde ! org
[Download RAW message or body]

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 <QtXml/QDomNode>
+
+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 <QtCore/QList>
-#include <QtCore/QObject>
 #include <QtCore/QPair>
 #include <QtCore/QString>
-#include <QtXml/QDomNode>
 
+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;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic