From 520d9beb9976ca5ff9b80bd646347f3a5eba4ac0 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Fri, 9 May 2008 07:24:52 +0000 Subject: [PATCH] Fix mem leak svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=805689 --- libscience/spectrumparser.cpp | 17 +++++++++++------ libscience/spectrumparser.h | 5 +++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libscience/spectrumparser.cpp b/libscience/spectrumparser.cpp index 0e9e02f..53a538c 100644 --- a/libscience/spectrumparser.cpp +++ b/libscience/spectrumparser.cpp @@ -16,9 +16,9 @@ email : cniehaus@kde.org #include #include #include -#include +#include -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(); diff --git a/libscience/spectrumparser.h b/libscience/spectrumparser.h index a903d76..df0d713 100644 --- a/libscience/spectrumparser.h +++ b/libscience/spectrumparser.h @@ -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 getSpectrums(); private: QString currentElementID; - + private: class Private; Private *const d; -- 2.47.3