From: Pino Toscano Date: Tue, 21 Feb 2006 10:07:50 +0000 (+0000) Subject: properly initialize all the pointers to zero even in the empty constructor; X-Git-Tag: v3.80.2~160 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=0038b5a8d40eb4e37bd0e4e34b98438d94c61645;p=libqmvoc.git properly initialize all the pointers to zero even in the empty constructor; removed the unused and not-so-useful constructor; some small fixes in the IsotopeParser svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=511926 --- diff --git a/libscience/isotope.cpp b/libscience/isotope.cpp index 883dc8b..e68bb01 100644 --- a/libscience/isotope.cpp +++ b/libscience/isotope.cpp @@ -21,24 +21,17 @@ #include "chemicaldataobject.h" #include -#include Isotope::Isotope() - : m_mass( 0 ), m_identifier( 0 ) -{ -} - -Isotope::Isotope( ChemicalDataObject* mass, ChemicalDataObject* ID ) : m_parentElementSymbol( 0 ), m_mass( 0 ), m_identifier( 0 ), m_spin( 0 ), m_magmoment( 0 ), m_halflife( 0 ), m_ecdecay( 0 ), m_betaplus( 0 ), m_betaminus( 0 ), m_alpha( 0 ) -{ - addData( mass ); - addData( ID ); +{ } -Isotope::~Isotope(){} - +Isotope::~Isotope() +{ +} ChemicalDataObject* Isotope::data() const { diff --git a/libscience/isotope.h b/libscience/isotope.h index 603a7a8..681559a 100644 --- a/libscience/isotope.h +++ b/libscience/isotope.h @@ -32,8 +32,10 @@ class ChemicalDataObject; class Isotope { public: + /** + * Constructs a new empty isotope. + */ Isotope(); - Isotope(ChemicalDataObject* mass, ChemicalDataObject* ID); virtual ~Isotope(); ChemicalDataObject* data() const; diff --git a/libscience/isotopeparser.cpp b/libscience/isotopeparser.cpp index 565516d..7f78ea4 100644 --- a/libscience/isotopeparser.cpp +++ b/libscience/isotopeparser.cpp @@ -101,6 +101,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->inIsotope = true; for (int i = 0; i < attrs.length(); ++i) { @@ -116,10 +117,10 @@ bool IsotopeParser::startElement(const QString&, const QString &localName, const } else if (d->inIsotope && localName == "halflife") { //X kDebug() << "bo:halfLife" << endl; d->inHalfLife = true; - if ( d->currentUnit != ChemicalDataObject::noUnit ) - d->currentDataObject->setUnit( d->currentUnit ); +//X if ( d->currentUnit != ChemicalDataObject::noUnit ) +//X d->currentDataObject->setUnit( d->currentUnit ); - d->currentUnit = ChemicalDataObject::noUnit; +//X d->currentUnit = ChemicalDataObject::noUnit; } else if (d->inIsotope && localName == "alphadecay"){ //X kDebug() << "bo:alphaDecay" << endl; d->inAlphaDecay = true; @@ -158,19 +159,12 @@ bool IsotopeParser::endElement( const QString&, const QString& localName, const { if ( localName == "isotope" ) { - d->currentIsotope->addData( new ChemicalDataObject( QVariant( d->currentElementSymbol ), ChemicalDataObject::symbol ) ); d->isotopes.append(d->currentIsotope); - d->currentIsotope = 0; d->currentDataObject = 0; + d->currentIsotope = 0; d->inIsotope = false; } - else if ( localName == "scalar" ) - { - if ( d->currentDataObject->type() == ChemicalDataObject::exactMass ){ - d->currentDataObject->setErrorValue( d->currentErrorValue ); - } - } else if ( localName == "isotopeList" ) {//a new list of isotopes start... //X kDebug() << "setting d->inElement FALSE" << endl; @@ -239,11 +233,19 @@ bool IsotopeParser::characters(const QString &ch) else//it is a non known value. Do not create a wrong object but return return true; + if ( type == ChemicalDataObject::exactMass ) + { + d->currentDataObject->setErrorValue( d->currentErrorValue ); + } + d->currentDataObject->setData( value ); d->currentDataObject->setType( type ); if ( d->currentIsotope ) + { d->currentIsotope->addData( d->currentDataObject ); + d->currentDataObject = 0; + } return true; }