Nullptr safety.

This commit is contained in:
Jeff Young 2025-06-08 11:45:25 +01:00
parent 530b4d683c
commit a85408d8ef

View File

@ -1177,21 +1177,20 @@ void UOP::Exec( CONTEXT* ctx )
// TODO: (and do this independently of unit specifics - e.g. MM + INCH needs to return one of the dimension // TODO: (and do this independently of unit specifics - e.g. MM + INCH needs to return one of the dimension
// TODO: types, but our units framework doesn't currently allow this. Therefore, use some heuristics to // TODO: types, but our units framework doesn't currently allow this. Therefore, use some heuristics to
// TODO: determine the resulting operation unit type for now // TODO: determine the resulting operation unit type for now
auto getOpResultUnits = []( const VALUE* aVal1, const VALUE* aVal2 ) auto getOpResultUnits =
{ []( const VALUE* aVal1, const VALUE* aVal2 )
// This condition can occur in, e.g., a unary negation operation {
if( aVal1->GetUnits() == EDA_UNITS::UNSCALED && aVal2->GetUnits() != EDA_UNITS::UNSCALED ) wxCHECK( aVal1 && aVal2, EDA_UNITS::UNSCALED );
{
return aVal2->GetUnits();
}
if( aVal1->GetUnits() != EDA_UNITS::UNSCALED && aVal2->GetUnits() == EDA_UNITS::UNSCALED ) // This condition can occur in, e.g., a unary negation operation
{ if( aVal1->GetUnits() == EDA_UNITS::UNSCALED && aVal2->GetUnits() != EDA_UNITS::UNSCALED )
return aVal1->GetUnits(); return aVal2->GetUnits();
}
return aVal2->GetUnits(); if( aVal1->GetUnits() != EDA_UNITS::UNSCALED && aVal2->GetUnits() == EDA_UNITS::UNSCALED )
}; return aVal1->GetUnits();
return aVal2->GetUnits();
};
EDA_UNITS resultUnits = EDA_UNITS::UNSCALED; EDA_UNITS resultUnits = EDA_UNITS::UNSCALED;