1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0032813: Units: ToSI and FromSI return cached dimension from previous request when parsing of unit sentence is failed

Cache value only if all necessary preparation steps are done.
This commit is contained in:
oan 2022-02-03 13:20:59 +03:00 committed by smoskvin
parent e1f5ac2c9b
commit ae38730d35

View File

@ -240,8 +240,6 @@ Standard_Real Units::ToSI(const Standard_Real aData,
Handle(Units_Dimensions) &dim)
{
if(lastunit != aUnit ) {
lastunit = TCollection_AsciiString(aUnit);
Units_UnitSentence unitsentence(aUnit);
if(!unitsentence.IsDone()) {
#ifdef OCCT_DEBUG
@ -257,6 +255,7 @@ Standard_Real Units::ToSI(const Standard_Real aData,
Handle(Units_ShiftedToken)::DownCast(token) ;
lastmove = stoken->Move();
}
lastunit = TCollection_AsciiString(aUnit);
lastdimension = token->Dimensions();
}
dim = lastdimension;
@ -286,7 +285,6 @@ Standard_Real Units::FromSI(const Standard_Real aData,
Handle(Units_Dimensions) &dim)
{
if(lastunit != aUnit) {
lastunit = TCollection_AsciiString(aUnit);
Units_UnitSentence unitsentence(aUnit);
if(!unitsentence.IsDone()) {
#ifdef OCCT_DEBUG
@ -302,6 +300,7 @@ Standard_Real Units::FromSI(const Standard_Real aData,
Handle(Units_ShiftedToken)::DownCast(token) ;
lastmove = stoken->Move();
}
lastunit = TCollection_AsciiString(aUnit);
lastdimension = token->Dimensions();
}
dim = lastdimension;