Skip to content

Commit

Permalink
Coverity issues:
Browse files Browse the repository at this point in the history
129643
129654
129689
129714
  • Loading branch information
wwmayer committed Aug 16, 2016
1 parent 0e0d344 commit 464a8f3
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/App/ColorModel.cpp
Expand Up @@ -52,7 +52,7 @@ ColorModel::~ColorModel ()
ColorModel& ColorModel::operator = (const ColorModel &rclM)
{
// first check if both objects are identical
if (this->_pclColors && this->_pclColors == rclM._pclColors)
if (this == &rclM)
return *this;

delete [] _pclColors;
Expand Down
4 changes: 4 additions & 0 deletions src/Base/FileTemplate.cpp
Expand Up @@ -41,6 +41,10 @@ using namespace Base;
* A more elaborate description of the constructor.
*/
ClassTemplate::ClassTemplate()
: enumPtr(0)
, enumVar(TVal1)
, publicVar(0)
, handler(0)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Base/Interpreter.cpp
Expand Up @@ -171,7 +171,7 @@ class PythonStdOutput : public Py::PythonExtension<PythonStdOutput>

InterpreterSingleton::InterpreterSingleton()
{
//Py_Initialize();
this->_global = 0;
}

InterpreterSingleton::~InterpreterSingleton()
Expand Down
3 changes: 2 additions & 1 deletion src/Base/Reader.cpp
Expand Up @@ -63,7 +63,8 @@ using namespace std;

Base::XMLReader::XMLReader(const char* FileName, std::istream& str)
: DocumentSchema(0), ProgramVersion(""), FileVersion(0), Level(0),
_File(FileName), _valid(false), _verbose(true)
CharacterCount(0), ReadType(None), _File(FileName), _valid(false),
_verbose(true)
{
#ifdef _MSC_VER
str.imbue(std::locale::empty());
Expand Down
66 changes: 40 additions & 26 deletions src/Base/Unit.cpp
Expand Up @@ -27,6 +27,7 @@
#endif

#include "Unit.h"
#include "Quantity.h"
#include "Exception.h"

using namespace Base;
Expand Down Expand Up @@ -79,27 +80,27 @@ Unit::Unit(int8_t Length,
(int32_t)Density);

Sig.Length = Length;
Sig.Mass = Mass;
Sig.Time = Time;
Sig.ElectricCurrent = ElectricCurrent;
Sig.ThermodynamicTemperature = ThermodynamicTemperature;
Sig.AmountOfSubstance = AmountOfSubstance;
Sig.LuminoseIntensity = LuminoseIntensity;
Sig.Angle = Angle;
Sig.Mass = Mass;
Sig.Time = Time;
Sig.ElectricCurrent = ElectricCurrent;
Sig.ThermodynamicTemperature = ThermodynamicTemperature;
Sig.AmountOfSubstance = AmountOfSubstance;
Sig.LuminoseIntensity = LuminoseIntensity;
Sig.Angle = Angle;
Sig.Density = Density;
}


Unit::Unit()
{
Sig.Length = 0;
Sig.Mass = 0;
Sig.Time = 0;
Sig.ElectricCurrent = 0;
Sig.ThermodynamicTemperature = 0;
Sig.AmountOfSubstance = 0;
Sig.LuminoseIntensity = 0;
Sig.Angle = 0;
Sig.Length = 0;
Sig.Mass = 0;
Sig.Time = 0;
Sig.ElectricCurrent = 0;
Sig.ThermodynamicTemperature = 0;
Sig.AmountOfSubstance = 0;
Sig.LuminoseIntensity = 0;
Sig.Angle = 0;
Sig.Density = 0;
}

Expand All @@ -108,12 +109,25 @@ Unit::Unit(const Unit& that)
this->Sig = that.Sig;
}

Unit::Unit(const std::string& Pars)
Unit::Unit(const QString& expr)
{

try {
*this = Quantity::parse(expr).getUnit();
}
catch (...) {
Sig.Length = 0;
Sig.Mass = 0;
Sig.Time = 0;
Sig.ElectricCurrent = 0;
Sig.ThermodynamicTemperature = 0;
Sig.AmountOfSubstance = 0;
Sig.LuminoseIntensity = 0;
Sig.Angle = 0;
Sig.Density = 0;
}
}

Unit Unit::pow(char exp)const
Unit Unit::pow(char exp) const
{
checkRange("pow()",
(int32_t)Sig.Length * (int32_t)exp,
Expand Down Expand Up @@ -223,15 +237,15 @@ Unit Unit::operator /(const Unit &right) const

Unit& Unit::operator = (const Unit &New)
{
Sig.Length = New.Sig.Length;
Sig.Mass = New.Sig.Mass ;
Sig.Time = New.Sig.Time ;
Sig.ElectricCurrent = New.Sig.ElectricCurrent ;
Sig.Length = New.Sig.Length;
Sig.Mass = New.Sig.Mass;
Sig.Time = New.Sig.Time;
Sig.ElectricCurrent = New.Sig.ElectricCurrent;
Sig.ThermodynamicTemperature = New.Sig.ThermodynamicTemperature;
Sig.AmountOfSubstance = New.Sig.AmountOfSubstance ;
Sig.LuminoseIntensity = New.Sig.LuminoseIntensity ;
Sig.Angle = New.Sig.Angle ;
Sig.Density = New.Sig.Density ;
Sig.AmountOfSubstance = New.Sig.AmountOfSubstance;
Sig.LuminoseIntensity = New.Sig.LuminoseIntensity;
Sig.Angle = New.Sig.Angle;
Sig.Density = New.Sig.Density;

return *this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Base/Unit.h
Expand Up @@ -65,7 +65,7 @@ class BaseExport Unit
Unit(int8_t Length,int8_t Mass=0,int8_t Time=0,int8_t ElectricCurrent=0,int8_t ThermodynamicTemperature=0,int8_t AmountOfSubstance=0,int8_t LuminoseIntensity=0,int8_t Angle=0, int8_t Density=0);
Unit(void);
Unit(const Unit&);
Unit(const std::string& Pars);
Unit(const QString& expr);
/// Destruction
~Unit () {}

Expand Down

0 comments on commit 464a8f3

Please sign in to comment.