Coverity issues:

129643
129654
129689
129714
This commit is contained in:
wmayer 2016-08-16 14:05:52 +02:00
parent 0e0d3446ba
commit 464a8f3860
6 changed files with 49 additions and 30 deletions

View File

@ -52,7 +52,7 @@ ColorModel::~ColorModel ()
ColorModel& ColorModel::operator = (const ColorModel &rclM) ColorModel& ColorModel::operator = (const ColorModel &rclM)
{ {
// first check if both objects are identical // first check if both objects are identical
if (this->_pclColors && this->_pclColors == rclM._pclColors) if (this == &rclM)
return *this; return *this;
delete [] _pclColors; delete [] _pclColors;

View File

@ -41,6 +41,10 @@ using namespace Base;
* A more elaborate description of the constructor. * A more elaborate description of the constructor.
*/ */
ClassTemplate::ClassTemplate() ClassTemplate::ClassTemplate()
: enumPtr(0)
, enumVar(TVal1)
, publicVar(0)
, handler(0)
{ {
} }

View File

@ -171,7 +171,7 @@ public:
InterpreterSingleton::InterpreterSingleton() InterpreterSingleton::InterpreterSingleton()
{ {
//Py_Initialize(); this->_global = 0;
} }
InterpreterSingleton::~InterpreterSingleton() InterpreterSingleton::~InterpreterSingleton()

View File

@ -63,7 +63,8 @@ using namespace std;
Base::XMLReader::XMLReader(const char* FileName, std::istream& str) Base::XMLReader::XMLReader(const char* FileName, std::istream& str)
: DocumentSchema(0), ProgramVersion(""), FileVersion(0), Level(0), : 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 #ifdef _MSC_VER
str.imbue(std::locale::empty()); str.imbue(std::locale::empty());

View File

@ -27,6 +27,7 @@
#endif #endif
#include "Unit.h" #include "Unit.h"
#include "Quantity.h"
#include "Exception.h" #include "Exception.h"
using namespace Base; using namespace Base;
@ -79,27 +80,27 @@ Unit::Unit(int8_t Length,
(int32_t)Density); (int32_t)Density);
Sig.Length = Length; Sig.Length = Length;
Sig.Mass = Mass; Sig.Mass = Mass;
Sig.Time = Time; Sig.Time = Time;
Sig.ElectricCurrent = ElectricCurrent; Sig.ElectricCurrent = ElectricCurrent;
Sig.ThermodynamicTemperature = ThermodynamicTemperature; Sig.ThermodynamicTemperature = ThermodynamicTemperature;
Sig.AmountOfSubstance = AmountOfSubstance; Sig.AmountOfSubstance = AmountOfSubstance;
Sig.LuminoseIntensity = LuminoseIntensity; Sig.LuminoseIntensity = LuminoseIntensity;
Sig.Angle = Angle; Sig.Angle = Angle;
Sig.Density = Density; Sig.Density = Density;
} }
Unit::Unit() Unit::Unit()
{ {
Sig.Length = 0; Sig.Length = 0;
Sig.Mass = 0; Sig.Mass = 0;
Sig.Time = 0; Sig.Time = 0;
Sig.ElectricCurrent = 0; Sig.ElectricCurrent = 0;
Sig.ThermodynamicTemperature = 0; Sig.ThermodynamicTemperature = 0;
Sig.AmountOfSubstance = 0; Sig.AmountOfSubstance = 0;
Sig.LuminoseIntensity = 0; Sig.LuminoseIntensity = 0;
Sig.Angle = 0; Sig.Angle = 0;
Sig.Density = 0; Sig.Density = 0;
} }
@ -108,12 +109,25 @@ Unit::Unit(const Unit& that)
this->Sig = that.Sig; 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()", checkRange("pow()",
(int32_t)Sig.Length * (int32_t)exp, (int32_t)Sig.Length * (int32_t)exp,
@ -223,15 +237,15 @@ Unit Unit::operator /(const Unit &right) const
Unit& Unit::operator = (const Unit &New) Unit& Unit::operator = (const Unit &New)
{ {
Sig.Length = New.Sig.Length; Sig.Length = New.Sig.Length;
Sig.Mass = New.Sig.Mass ; Sig.Mass = New.Sig.Mass;
Sig.Time = New.Sig.Time ; Sig.Time = New.Sig.Time;
Sig.ElectricCurrent = New.Sig.ElectricCurrent ; Sig.ElectricCurrent = New.Sig.ElectricCurrent;
Sig.ThermodynamicTemperature = New.Sig.ThermodynamicTemperature; Sig.ThermodynamicTemperature = New.Sig.ThermodynamicTemperature;
Sig.AmountOfSubstance = New.Sig.AmountOfSubstance ; Sig.AmountOfSubstance = New.Sig.AmountOfSubstance;
Sig.LuminoseIntensity = New.Sig.LuminoseIntensity ; Sig.LuminoseIntensity = New.Sig.LuminoseIntensity;
Sig.Angle = New.Sig.Angle ; Sig.Angle = New.Sig.Angle;
Sig.Density = New.Sig.Density ; Sig.Density = New.Sig.Density;
return *this; return *this;
} }

View File

@ -65,7 +65,7 @@ public:
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(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(void);
Unit(const Unit&); Unit(const Unit&);
Unit(const std::string& Pars); Unit(const QString& expr);
/// Destruction /// Destruction
~Unit () {} ~Unit () {}