diff --git a/pvDataApp/factory/Convert.cpp b/pvDataApp/factory/Convert.cpp index 7a43cd8..2633215 100644 --- a/pvDataApp/factory/Convert.cpp +++ b/pvDataApp/factory/Convert.cpp @@ -45,10 +45,7 @@ static std::vector split(String commaSeparatedList) { } Convert::Convert() -: pvDataCreate(getPVDataCreate()), - trueString("true"), - falseString("false"), - illegalScalarType("Illegal ScalarType") +: pvDataCreate(getPVDataCreate()) {} @@ -298,8 +295,7 @@ void Convert::copyStructure(PVStructurePtr const & from, PVStructurePtr const & { if(to->isImmutable()) { if(from==to) return; - String message("Convert.copyStructure destination is immutable"); - throw std::invalid_argument(message); + throw std::invalid_argument("Convert.copyStructure destination is immutable"); } if(from==to) return; PVFieldPtrArray const & fromDatas = from->getPVFields(); @@ -343,6 +339,10 @@ void Convert::copyStructure(PVStructurePtr const & from, PVStructurePtr const & String message("Convert.copyStructure Illegal copyStructure"); throw std::invalid_argument(message); } + if(toData->isImmutable()) { + if(fromData==toData) return; + throw std::invalid_argument("Convert.copyStructure destination is immutable"); + } switch(fromType) { case scalar: { @@ -415,8 +415,4 @@ ConvertPtr Convert::getConvert() return convert; } -ConvertPtr getConvert() { - return Convert::getConvert(); -} - }} diff --git a/pvDataApp/pv/convert.h b/pvDataApp/pv/convert.h index 4afa9e5..1aa5e71 100644 --- a/pvDataApp/pv/convert.h +++ b/pvDataApp/pv/convert.h @@ -89,7 +89,7 @@ public: * @param Second field * @return (false, true) if the fields (are not, are) the same. */ - bool equals(PVFieldPtr const &a,PVFieldPtr const &b) + inline bool equals(PVFieldPtr const &a,PVFieldPtr const &b) { return *a==*b; } @@ -101,7 +101,7 @@ public: * @param Second field * @return (false, true) if the fields (are not, are) the same. */ - bool equals(PVField &a,PVField &b) + inline bool equals(PVField &a,PVField &b) { return a==b; } @@ -820,12 +820,9 @@ public: private: Convert(); PVDataCreatePtr pvDataCreate; - String trueString; - String falseString; - String illegalScalarType; }; -extern ConvertPtr getConvert(); +static inline ConvertPtr getConvert() { return Convert::getConvert(); } }} #endif /* CONVERT_H */ diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h index 3ef001c..164406f 100644 --- a/pvDataApp/pv/pvData.h +++ b/pvDataApp/pv/pvData.h @@ -501,6 +501,10 @@ protected: } virtual void assign(const PVScalar& scalar) { + if(this==&scalar) + return; + if(isImmutable()) + throw std::invalid_argument("Destination is immutable"); T result; scalar.getAs((void*)&result, typeCode); put(result);