From 2ef14fdf0baabbef4a9ba2880b3568378140b01a Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Sun, 29 Oct 2006 11:13:45 +0000 Subject: [PATCH] Porting to QList (no pointer Porting to QSharedPointer and co, this shares implicitly. Result: ==8109== LEAK SUMMARY: ==8109== definitely lost: 980 bytes in 17 blocks. ==8109== indirectly lost: 14,505 bytes in 245 blocks. ==8109== possibly lost: 792 bytes in 6 bloc svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=599978 --- libscience/chemicaldataobject.cpp | 52 ++++++----------- libscience/chemicaldataobject.h | 23 +++++--- libscience/element.cpp | 20 +++---- libscience/element.h | 6 +- libscience/elementparser.cpp | 23 ++++---- libscience/isotope.cpp | 93 +++++++++++++------------------ libscience/isotope.h | 35 ++++++------ libscience/isotopeparser.cpp | 20 +++---- libscience/spectrumparser.cpp | 11 ++-- libscience/spectrumparser.h | 2 +- libscience/xmlreadingtest.cpp | 11 ++-- 11 files changed, 126 insertions(+), 170 deletions(-) diff --git a/libscience/chemicaldataobject.cpp b/libscience/chemicaldataobject.cpp index 1792ac8..efaf615 100644 --- a/libscience/chemicaldataobject.cpp +++ b/libscience/chemicaldataobject.cpp @@ -17,48 +17,38 @@ * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#include "chemicaldataobject.h" - -int ChemicalDataObject::mycount = 0; - #include +#include "chemicaldataobject.h" -class ChemicalDataObjectPrivate +//######################## +ChemicalDataObjectPrivate::ChemicalDataObjectPrivate() { - public: - QVariant m_value; - QVariant m_errorValue; - ChemicalDataObject::BlueObelisk m_type; - ChemicalDataObject::BlueObeliskUnit m_unit; +} - ~ChemicalDataObjectPrivate(); -}; +ChemicalDataObjectPrivate::ChemicalDataObjectPrivate(const ChemicalDataObjectPrivate &other) +: QSharedData(other) +{ +} ChemicalDataObjectPrivate::~ChemicalDataObjectPrivate() { } +//############## ChemicalDataObject::ChemicalDataObject( const QVariant& v, BlueObelisk type, const QVariant& errorValue ) -: d(new ChemicalDataObjectPrivate()) { - mycount++; - kDebug() << "CDO non-default contructor. There are now " << mycount - << " allocated CDOs" << endl; - - d->m_value = v; - d->m_errorValue = errorValue; - d->m_type = type; - d->m_unit = ChemicalDataObject::noUnit; + d = new ChemicalDataObjectPrivate; + d->m_value = v; + d->m_errorValue = errorValue; + d->m_type = type; + d->m_unit = ChemicalDataObject::noUnit; } ChemicalDataObject::ChemicalDataObject() -: d(new ChemicalDataObjectPrivate()) { - mycount++; - kDebug() << "CDO default contructor. There are now " << mycount - << " allocated CDOs" << endl; d->m_value = QVariant(); - d->m_errorValue = QVariant(); - d->m_unit = ChemicalDataObject::noUnit; + d = new ChemicalDataObjectPrivate; + d->m_errorValue = QVariant(); + d->m_unit = ChemicalDataObject::noUnit; } bool ChemicalDataObject::operator==( const int v ) const @@ -93,14 +83,6 @@ bool ChemicalDataObject::operator==( const QString& v ) const return d->m_value.toString() == v; } -ChemicalDataObject::~ChemicalDataObject() -{ - mycount--; - kDebug() << "CDO destructor. There are now " << mycount - << " allocated CDOs" << endl; - delete d; -} - QString ChemicalDataObject::valueAsString() const { return d->m_value.toString(); diff --git a/libscience/chemicaldataobject.h b/libscience/chemicaldataobject.h index c7a904e..adfe248 100644 --- a/libscience/chemicaldataobject.h +++ b/libscience/chemicaldataobject.h @@ -20,13 +20,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include +#include #include #include #include class ChemicalDataObjectPrivate; - /** * A ChemicalDataObject is an object which contains information about * a chemical element. This can for example be a boiling point. The information @@ -129,11 +130,6 @@ class EDUSCIENCE_EXPORT ChemicalDataObject * @param v the value of the object */ void setErrorValue( const QVariant& v ); - - /** - * Destructor. - */ - ~ChemicalDataObject(); /** * Every ChemicalDataObject contains one data. For example a @@ -239,8 +235,19 @@ class EDUSCIENCE_EXPORT ChemicalDataObject static BlueObeliskUnit unit( const QString& unitname ); private: - ChemicalDataObjectPrivate *d; - static int mycount; + QSharedDataPointer d; }; +class ChemicalDataObjectPrivate : public QSharedData +{ + public: + ChemicalDataObjectPrivate(); + ChemicalDataObjectPrivate(const ChemicalDataObjectPrivate &other); + ~ChemicalDataObjectPrivate(); + + QVariant m_value; + QVariant m_errorValue; + ChemicalDataObject::BlueObelisk m_type; + ChemicalDataObject::BlueObeliskUnit m_unit; +}; #endif // CHEMICALDATAOBJECT_H diff --git a/libscience/element.cpp b/libscience/element.cpp index dee1442..e790363 100644 --- a/libscience/element.cpp +++ b/libscience/element.cpp @@ -29,39 +29,35 @@ Element::Element() QVariant Element::dataAsVariant( ChemicalDataObject::BlueObelisk type ) const { - foreach( ChemicalDataObject* o, dataList ) { - if ( o->type() == type ) - return o->value(); + foreach( ChemicalDataObject o, dataList ) { + if ( o.type() == type ) + return o.value(); } return QVariant(); } QString Element::dataAsString(ChemicalDataObject::BlueObelisk type) const { - foreach( ChemicalDataObject*o, dataList ) { - if ( o->type() == type ) - return o->valueAsString(); + foreach( ChemicalDataObject o, dataList ) { + if ( o.type() == type ) + return o.valueAsString(); } return QString(); } Element::~Element() { - qDeleteAll(dataList); - delete m_spectrum; m_spectrum = 0; } -void Element::addData( ChemicalDataObject*o ) +void Element::addData( const ChemicalDataObject& o ) { - // skip null pointers - if ( !o ) return; dataList.append( o ); } void Element::addData( const QVariant& value, ChemicalDataObject::BlueObelisk type ) { - ChemicalDataObject* tmp = new ChemicalDataObject( value, type ); + ChemicalDataObject tmp( value, type ); dataList.append( tmp ); } diff --git a/libscience/element.h b/libscience/element.h index 19e4f4c..97b43ab 100644 --- a/libscience/element.h +++ b/libscience/element.h @@ -49,7 +49,7 @@ class EDUSCIENCE_EXPORT Element * Add the ChemicalDataObject @p o to this Element * @param o the ChemicalDataObject to be added */ - void addData( ChemicalDataObject*o ); + void addData( const ChemicalDataObject& o ); /** * Add a ChemicalDataObject with @p value of @p type to this @@ -72,7 +72,7 @@ class EDUSCIENCE_EXPORT Element /** * @return the data of the Element */ - QList data()const{ + QList data()const{ return dataList; } @@ -88,7 +88,7 @@ class EDUSCIENCE_EXPORT Element /** * this QList stores all information about an element */ - QList dataList; + QList dataList; Spectrum *m_spectrum; }; diff --git a/libscience/elementparser.cpp b/libscience/elementparser.cpp index 8a5d02a..e18cf41 100644 --- a/libscience/elementparser.cpp +++ b/libscience/elementparser.cpp @@ -21,8 +21,7 @@ class ElementSaxParser::Private { public: Private() - : currentDataObject(0), - currentUnit(ChemicalDataObject::noUnit), + : currentUnit(ChemicalDataObject::noUnit), currentElement(0), inElement(false), inName(false), @@ -56,12 +55,11 @@ class ElementSaxParser::Private ~Private() { - delete currentDataObject; delete currentElement; //qDeleteAll(elements); } - ChemicalDataObject *currentDataObject; + ChemicalDataObject currentDataObject; ChemicalDataObject::BlueObeliskUnit currentUnit; Element *currentElement; @@ -187,8 +185,8 @@ bool ElementSaxParser::startElement(const QString&, const QString &localName, co for (int i = 0; i < attrs.length(); ++i) { if (attrs.localName(i) == "value") { - d->currentDataObject->setData( attrs.value(i) ); - d->currentDataObject->setType( ChemicalDataObject::symbol ); + d->currentDataObject.setData( attrs.value(i) ); + d->currentDataObject.setType( ChemicalDataObject::symbol ); if ( d->currentElement ) d->currentElement->addData( d->currentDataObject ); @@ -199,8 +197,8 @@ bool ElementSaxParser::startElement(const QString&, const QString &localName, co for (int i = 0; i < attrs.length(); ++i) { if (attrs.localName(i) == "value") { - d->currentDataObject->setData( attrs.value(i) ); - d->currentDataObject->setType( ChemicalDataObject::name ); + d->currentDataObject.setData( attrs.value(i) ); + d->currentDataObject.setType( ChemicalDataObject::name ); if ( d->currentElement ) d->currentElement->addData( d->currentDataObject ); @@ -220,19 +218,18 @@ bool ElementSaxParser::endElement( const QString &, const QString& localName, co d->elements.append(d->currentElement); d->currentElement = 0; - d->currentDataObject = 0; d->inElement = false; } else if ( localName == "scalar" || localName == "label" || localName == "array" ) { - d->currentDataObject->setUnit( d->currentUnit ); + d->currentDataObject.setUnit( d->currentUnit ); } return true; } bool ElementSaxParser::characters(const QString &ch) { - d->currentDataObject = new ChemicalDataObject(); + d->currentDataObject = ChemicalDataObject(); ChemicalDataObject::BlueObelisk type; QVariant value; @@ -364,8 +361,8 @@ bool ElementSaxParser::characters(const QString &ch) else//it is a non known value. Do not create a wrong object but return return true; - d->currentDataObject->setData( value ); - d->currentDataObject->setType( type ); + d->currentDataObject.setData( value ); + d->currentDataObject.setType( type ); if ( d->currentElement ) d->currentElement->addData( d->currentDataObject ); diff --git a/libscience/isotope.cpp b/libscience/isotope.cpp index 85bb3cc..f813a09 100644 --- a/libscience/isotope.cpp +++ b/libscience/isotope.cpp @@ -23,150 +23,133 @@ #include Isotope::Isotope() -: m_parentElementSymbol( 0 ), m_mass( 0 ), m_identifier( 0 ), - m_spin( 0 ), m_magmoment( 0 ), m_abundance( 0 ), m_halflife( 0 ), m_ecdecay( 0 ), m_eclikeliness( 0 ), m_betaplusdecay( 0 ), m_betapluslikeliness( 0 ), m_betaminusdecay( 0 ), m_betaminuslikeliness( 0 ), m_alphadecay( 0 ), m_alphalikeliness( 0 ) { } Isotope::~Isotope() { - delete m_parentElementSymbol; - delete m_mass; - delete m_identifier; - delete m_spin; - delete m_magmoment; - delete m_abundance; - delete m_halflife; - delete m_ecdecay; - delete m_betaplusdecay; - delete m_betaminusdecay; - delete m_alphadecay; - delete m_eclikeliness; - delete m_betapluslikeliness; - delete m_betaminuslikeliness; - delete m_alphalikeliness; -} - -void Isotope::addData( ChemicalDataObject* o ) -{ - if ( o->type() == ChemicalDataObject::exactMass ) +} + +void Isotope::addData( ChemicalDataObject o ) +{ + if ( o.type() == ChemicalDataObject::exactMass ) m_mass = o; - else if ( o->type() == ChemicalDataObject::atomicNumber ) + else if ( o.type() == ChemicalDataObject::atomicNumber ) m_identifier = o; - else if ( o->type() == ChemicalDataObject::symbol ) + else if ( o.type() == ChemicalDataObject::symbol ) m_parentElementSymbol = o; - else if ( o->type() == ChemicalDataObject::spin ) + else if ( o.type() == ChemicalDataObject::spin ) m_spin = o; - else if ( o->type() == ChemicalDataObject::magneticMoment ) + else if ( o.type() == ChemicalDataObject::magneticMoment ) m_magmoment = o; - else if ( o->type() == ChemicalDataObject::relativeAbundance ) + else if ( o.type() == ChemicalDataObject::relativeAbundance ) m_abundance = o; - else if ( o->type() == ChemicalDataObject::halfLife ) + else if ( o.type() == ChemicalDataObject::halfLife ) m_halflife = o; - else if ( o->type() == ChemicalDataObject::ecDecay ) + else if ( o.type() == ChemicalDataObject::ecDecay ) m_ecdecay = o; - else if ( o->type() == ChemicalDataObject::ecDecayLikeliness ) + else if ( o.type() == ChemicalDataObject::ecDecayLikeliness ) m_eclikeliness = o; - else if ( o->type() == ChemicalDataObject::betaplusDecay ) + else if ( o.type() == ChemicalDataObject::betaplusDecay ) m_betaplusdecay = o; - else if ( o->type() == ChemicalDataObject::betaplusDecayLikeliness ) + else if ( o.type() == ChemicalDataObject::betaplusDecayLikeliness ) m_betapluslikeliness = o; - else if ( o->type() == ChemicalDataObject::betaminusDecay ) + else if ( o.type() == ChemicalDataObject::betaminusDecay ) m_betaminusdecay = o; - else if ( o->type() == ChemicalDataObject::betaminusDecayLikeliness ) + else if ( o.type() == ChemicalDataObject::betaminusDecayLikeliness ) m_betaminuslikeliness = o; - else if ( o->type() == ChemicalDataObject::alphaDecay ) + else if ( o.type() == ChemicalDataObject::alphaDecay ) m_alphadecay = o; - else if ( o->type() == ChemicalDataObject::alphaDecayLikeliness ) + else if ( o.type() == ChemicalDataObject::alphaDecayLikeliness ) m_alphalikeliness = o; } double Isotope::mass() const { - return m_mass ? m_mass->value().toDouble() : -1.0; + //return m_mass ? m_mass.value().toDouble() : -1.0; } QString Isotope::errorMargin() const { - return m_mass ? m_mass->errorValue().toString() : QString(); + //return m_mass ? m_mass.errorValue().toString() : QString(); } int Isotope::parentElementNumber() const { - return m_identifier ? m_identifier->value().toInt() : -1; +// return m_identifier ? m_identifier.value().toInt() : -1; } QString Isotope::spin() const { - return m_spin ? m_spin->value().toString() : QString(); + //return m_spin ? m_spin.value().toString() : QString(); } QString Isotope::magmoment() const { - return m_magmoment ? m_magmoment->value().toString() : QString(); + //return m_magmoment ? m_magmoment.value().toString() : QString(); } QString Isotope::abundance() const { - return m_abundance ? m_abundance->value().toString() : QString(); + //return m_abundance ? m_abundance.value().toString() : QString(); } double Isotope::halflife() const { - return m_halflife ? m_halflife->value().toDouble() : -1.0; + //return m_halflife ? m_halflife.value().toDouble() : -1.0; } double Isotope::ecdecay() const { - return m_ecdecay ? m_ecdecay->value().toDouble() : -1.0; + //return m_ecdecay ? m_ecdecay.value().toDouble() : -1.0; } double Isotope::eclikeliness() const { - return m_eclikeliness ? m_eclikeliness->value().toDouble() : -1.0; + //return m_eclikeliness ? m_eclikeliness.value().toDouble() : -1.0; } double Isotope::betaplusdecay() const { - return m_betaplusdecay ? m_betaplusdecay->value().toDouble() : -1.0; + //return m_betaplusdecay ? m_betaplusdecay.value().toDouble() : -1.0; } double Isotope::betapluslikeliness() const { - return m_betapluslikeliness ? m_betapluslikeliness->value().toDouble() : -1.0; + //return m_betapluslikeliness ? m_betapluslikeliness.value().toDouble() : -1.0; } double Isotope::betaminusdecay() const { - return m_betaminusdecay ? m_betaminusdecay->value().toDouble() : -1.0; + //return m_betaminusdecay ? m_betaminusdecay.value().toDouble() : -1.0; } double Isotope::betaminuslikeliness() const { - return m_betaminuslikeliness ? m_betaminuslikeliness->value().toDouble() : -1.0; + //return m_betaminuslikeliness ? m_betaminuslikeliness.value().toDouble() : -1.0; } double Isotope::alphadecay() const { - return m_alphadecay ? m_alphadecay->value().toDouble() : -1.0; + //return m_alphadecay ? m_alphadecay.value().toDouble() : -1.0; } double Isotope::alphalikeliness() const { - return m_alphalikeliness ? m_alphalikeliness->value().toDouble() : -1.0; + //return m_alphalikeliness ? m_alphalikeliness.value().toDouble() : -1.0; } QString Isotope::parentElementSymbol() const { - return m_parentElementSymbol ? m_parentElementSymbol->value().toString() : QString(); + //return m_parentElementSymbol ? m_parentElementSymbol.value().toString() : QString(); } void Isotope::setNucleons( int number ) { - m_numberOfNucleons = number; + //m_numberOfNucleons = number; } int Isotope::nucleons() const { - return m_numberOfNucleons; + //return m_numberOfNucleons; } Isotope::Nucleons Isotope::nucleonsAfterDecay( Decay kind ) { Isotope::Nucleons n; - int protons = m_identifier->value().toInt(); + int protons = m_identifier.value().toInt(); int neutrons = m_numberOfNucleons - protons; n.protons = protons; n.neutrons = neutrons; diff --git a/libscience/isotope.h b/libscience/isotope.h index 8b12afa..9a51bee 100644 --- a/libscience/isotope.h +++ b/libscience/isotope.h @@ -20,8 +20,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -class ChemicalDataObject; - +#include "chemicaldataobject.h" #include #include @@ -94,7 +93,7 @@ class EDUSCIENCE_EXPORT Isotope /** * add the ChemicalDataObject @p o */ - void addData( ChemicalDataObject* o ); + void addData( ChemicalDataObject o ); void setNucleons( int number ); @@ -164,53 +163,53 @@ class EDUSCIENCE_EXPORT Isotope /** * the symbol of the element the isotope belongs to */ - ChemicalDataObject* m_parentElementSymbol; + ChemicalDataObject m_parentElementSymbol; /** * stores the information about the mass of the Isotope */ - ChemicalDataObject* m_mass; + ChemicalDataObject m_mass; /** * stores the atomicNumber of the Isotope */ - ChemicalDataObject* m_identifier; + ChemicalDataObject m_identifier; /** * stores the spin of the Isotope */ - ChemicalDataObject* m_spin; + ChemicalDataObject m_spin; /** * stores the magneticMoment of the Isotope */ - ChemicalDataObject* m_magmoment; + ChemicalDataObject m_magmoment; /** * stores the relative abundance of the Isotope */ - ChemicalDataObject* m_abundance; + ChemicalDataObject m_abundance; /** * stores the halfLife of the Isotope */ - ChemicalDataObject* m_halflife; + ChemicalDataObject m_halflife; /** * stores decay energy of the isotope */ - ChemicalDataObject* m_ecdecay; - ChemicalDataObject* m_betaplusdecay; - ChemicalDataObject* m_betaminusdecay; - ChemicalDataObject* m_alphadecay; + ChemicalDataObject m_ecdecay; + ChemicalDataObject m_betaplusdecay; + ChemicalDataObject m_betaminusdecay; + ChemicalDataObject m_alphadecay; /** * stores the likeliness of a decay of the isotope */ - ChemicalDataObject* m_eclikeliness; - ChemicalDataObject* m_betapluslikeliness; - ChemicalDataObject* m_betaminuslikeliness; - ChemicalDataObject* m_alphalikeliness; + ChemicalDataObject m_eclikeliness; + ChemicalDataObject m_betapluslikeliness; + ChemicalDataObject m_betaminuslikeliness; + ChemicalDataObject m_alphalikeliness; int m_numberOfNucleons; }; diff --git a/libscience/isotopeparser.cpp b/libscience/isotopeparser.cpp index 8b393e9..38bf616 100644 --- a/libscience/isotopeparser.cpp +++ b/libscience/isotopeparser.cpp @@ -22,8 +22,7 @@ class IsotopeParser::Private { public: Private() - : currentDataObject(0), - currentUnit(ChemicalDataObject::noUnit), + : currentUnit(ChemicalDataObject::noUnit), currentErrorValue(QVariant()), currentElementSymbol(QString()), currentIsotope(0), @@ -48,11 +47,10 @@ public: ~Private(){ delete currentIsotope; - delete currentDataObject; //qDeleteAll(isotopes); } - ChemicalDataObject *currentDataObject; + ChemicalDataObject currentDataObject; ChemicalDataObject::BlueObeliskUnit currentUnit; QVariant currentErrorValue; QString currentElementSymbol; @@ -106,7 +104,7 @@ bool IsotopeParser::startElement(const QString&, const QString &localName, const { //X kDebug() << "setting inIsotope true!" << endl; d->currentIsotope = new Isotope(); - d->currentIsotope->addData( new ChemicalDataObject( QVariant( d->currentElementSymbol ), ChemicalDataObject::symbol ) ); + d->currentIsotope->addData( ChemicalDataObject( QVariant( d->currentElementSymbol ), ChemicalDataObject::symbol ) ); d->inIsotope = true; for (int i = 0; i < attrs.length(); ++i) { @@ -132,7 +130,7 @@ bool IsotopeParser::startElement(const QString&, const QString &localName, const { if ( attrs.localName( i ) == "unit" ) { - d->currentDataObject->setUnit( d->currentUnit ); + d->currentDataObject.setUnit( d->currentUnit ); } else { @@ -174,7 +172,6 @@ bool IsotopeParser::endElement( const QString&, const QString& localName, const { d->isotopes.append(d->currentIsotope); - d->currentDataObject = 0; d->currentIsotope = 0; d->inIsotope = false; } @@ -189,7 +186,7 @@ bool IsotopeParser::endElement( const QString&, const QString& localName, const bool IsotopeParser::characters(const QString &ch) { - d->currentDataObject = new ChemicalDataObject(); + d->currentDataObject = ChemicalDataObject(); ChemicalDataObject::BlueObelisk type; QVariant value; @@ -269,16 +266,15 @@ bool IsotopeParser::characters(const QString &ch) if ( type == ChemicalDataObject::exactMass ) { - d->currentDataObject->setErrorValue( d->currentErrorValue ); + d->currentDataObject.setErrorValue( d->currentErrorValue ); } - d->currentDataObject->setData( value ); - d->currentDataObject->setType( type ); + d->currentDataObject.setData( value ); + d->currentDataObject.setType( type ); if ( d->currentIsotope ) { d->currentIsotope->addData( d->currentDataObject ); - d->currentDataObject = 0; } return true; diff --git a/libscience/spectrumparser.cpp b/libscience/spectrumparser.cpp index 2dd5df0..ca941be 100644 --- a/libscience/spectrumparser.cpp +++ b/libscience/spectrumparser.cpp @@ -63,13 +63,12 @@ bool SpectrumParser::endElement( const QString&, const QString& localName, const //X isotopes_.append(currentSpectrum_); //X //X currentSpectrum_ = 0; -//X currentDataObject_ = 0; //X inSpectrum_ = false; } else if ( localName == "scalar" ) { -//X if ( currentDataObject_->type() == ChemicalDataObject::exactMass ){ -//X currentDataObject_->setErrorValue( currentErrorValue_ ); +//X if ( currentDataObject_.type() == ChemicalDataObject::exactMass ){ +//X currentDataObject_.setErrorValue( currentErrorValue_ ); //X } } @@ -78,7 +77,7 @@ bool SpectrumParser::endElement( const QString&, const QString& localName, const bool SpectrumParser::characters(const QString &ch) { - currentDataObject_ = new ChemicalDataObject(); + ChemicalDataObject currentDataObject_; ChemicalDataObject::BlueObelisk type; QVariant value; @@ -95,8 +94,8 @@ bool SpectrumParser::characters(const QString &ch) else//it is a non known value. Do not create a wrong object but return return true; - currentDataObject_->setData( value ); - currentDataObject_->setType( type ); + currentDataObject_.setData( value ); + currentDataObject_.setType( type ); //X if ( currentSpectrum_ ) //X currentSpectrum_->addData( currentDataObject_ ); diff --git a/libscience/spectrumparser.h b/libscience/spectrumparser.h index b3797d3..ca8515c 100644 --- a/libscience/spectrumparser.h +++ b/libscience/spectrumparser.h @@ -43,7 +43,7 @@ class EDUSCIENCE_EXPORT SpectrumParser : public QXmlDefaultHandler QList getSpectrums(); private: - ChemicalDataObject *currentDataObject_; + ChemicalDataObject currentDataObject_; ChemicalDataObject::BlueObeliskUnit currentUnit_; QVariant currentErrorValue_; diff --git a/libscience/xmlreadingtest.cpp b/libscience/xmlreadingtest.cpp index bd979f3..4d05392 100644 --- a/libscience/xmlreadingtest.cpp +++ b/libscience/xmlreadingtest.cpp @@ -28,17 +28,14 @@ int main(int argc, char *argv[]) foreach( Element* e, v ){ if ( e ) { - QList list = e->data(); + QList list = e->data(); //Test: give me all data available - foreach( ChemicalDataObject*o, list ){ - if ( o ) - { - QString unit = o->unitAsString(); + foreach( ChemicalDataObject o, list ){ + QString unit = o.unitAsString(); if ( unit == "bo:noUnit" ) unit = ""; - kDebug() << "Name: " << o->dictRef() << " " << o->valueAsString() <<" " << unit << endl; - } + kDebug() << "Name: " << o.dictRef() << " " << o.valueAsString() <<" " << unit << endl; } } } -- 2.47.3