From ae38730d3520fc8d0fbe4a3b9a97afd0cebe6df8 Mon Sep 17 00:00:00 2001 From: oan Date: Thu, 3 Feb 2022 13:20:59 +0300 Subject: [PATCH] 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. --- src/Units/Units.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Units/Units.cxx b/src/Units/Units.cxx index 802121ffe0..202f63c892 100644 --- a/src/Units/Units.cxx +++ b/src/Units/Units.cxx @@ -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;