]> Git trees. - libqmvoc.git/commitdiff
properly initialize all the pointers to zero even in the empty constructor;
authorPino Toscano <pino@kde.org>
Tue, 21 Feb 2006 10:07:50 +0000 (10:07 +0000)
committerPino Toscano <pino@kde.org>
Tue, 21 Feb 2006 10:07:50 +0000 (10:07 +0000)
removed the unused and not-so-useful constructor;
some small fixes in the IsotopeParser

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=511926

libscience/isotope.cpp
libscience/isotope.h
libscience/isotopeparser.cpp

index 883dc8b20c4f2245d55c3b049b965d3535e8360b..e68bb014cfb98bb696e284d8ddeee0c7ca14c089 100644 (file)
 #include "chemicaldataobject.h"
 
 #include <kdebug.h>
-#include <klocale.h>
 
 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
 {
index 603a7a8b4dd31e5b99f4e4fee4340510b93af49c..681559aacaa29ecb27ce2714b238fd3cf8f62ae9 100644 (file)
@@ -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;
index 565516df092d6a8e461f0b1477ddae476d1d2e03..7f78ea41f6582afaa1a88659e95780d8b0f91e03 100644 (file)
@@ -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;
 }