]> Git trees. - libqmvoc.git/commitdiff
Fix mem leak
authorLaurent Montel <montel@kde.org>
Fri, 9 May 2008 07:24:52 +0000 (07:24 +0000)
committerLaurent Montel <montel@kde.org>
Fri, 9 May 2008 07:24:52 +0000 (07:24 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=805689

libscience/spectrumparser.cpp
libscience/spectrumparser.h

index 0e9e02fa0230cf001a6f6623a854143c2f6fa67c..53a538c2e63b2f9204b4e2b169356610d6fb4509 100644 (file)
@@ -16,9 +16,9 @@ email                : cniehaus@kde.org
 #include <qdom.h>
 #include <QList>
 #include <QFile>
-#include <QDebug> 
+#include <QDebug>
 
-class SpectrumParser ::Private
+class SpectrumParser::Private
 {
     public:
         Private()
@@ -56,15 +56,20 @@ SpectrumParser::SpectrumParser()
 {
 }
 
+SpectrumParser::~SpectrumParser()
+{
+    delete d;
+}
+
 bool SpectrumParser::startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs)
 {
-       if (localName == "spectrum") 
+       if (localName == "spectrum")
        {
                d->currentSpectrum = new Spectrum();
                d->inSpectrum_ = true;
-               
+
                //now save the element of the current spectrum
-               for (int i = 0; i < attrs.length(); ++i) 
+               for (int i = 0; i < attrs.length(); ++i)
                {
                     if ( attrs.localName( i ) == "id" ) {
                         currentElementID = attrs.value( i );
@@ -75,7 +80,7 @@ bool SpectrumParser::startElement(const QString&, const QString &localName, cons
        }
        else if (d->inSpectrum_ && d->inPeakList_ && localName == "peak") {
                d->inPeak_ = true;
-               for (int i = 0; i < attrs.length(); ++i) 
+               for (int i = 0; i < attrs.length(); ++i)
                {
                        if (attrs.localName(i) == "xValue"){
                                 d->intensity = attrs.value(i).toInt();
index a903d76a77de0574151a6322d8d89b5431e9b680..df0d7135f68ac6f11dab5a7e5ef8016ac762fcf9 100644 (file)
@@ -34,17 +34,18 @@ class SCIENCE_EXPORT SpectrumParser : public QXmlDefaultHandler
                 * Constructor
                 */
                SpectrumParser();
+                ~SpectrumParser();
                bool startElement( const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs );
 
                bool endElement( const QString& namespaceURI, const QString &localName, const QString& qName );
-               
+
                bool characters(const QString &ch);
 
                QList<Spectrum*> getSpectrums();
 
        private:
                 QString currentElementID;
-       
+
         private:
                class Private;
                Private *const d;