mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-30 17:10:19 -05:00
Clamp UI values if field supports clampValue method
Added a compile-time check to call clampValue on fields that support it before setting values from the UI. This ensures values are clamped to valid limits automatically when applicable.
This commit is contained in:
1 parent
8f884c684b
commit
483a4a9b7b
1 file changed
+7
@@ -95,6 +95,13 @@ void PdmFieldUiCap<FieldType>::setValueFromUiEditor( const QVariant& uiValue, bo
|
||||
{
|
||||
typename FieldType::FieldDataType value;
|
||||
PdmUiFieldSpecialization<typename FieldType::FieldDataType>::setFromVariant( uiValue, value );
|
||||
|
||||
// Clamp value if the field has a clampValue method
|
||||
if constexpr ( requires { m_field->clampValue( value ); } )
|
||||
{
|
||||
value = m_field->clampValue( value );
|
||||
}
|
||||
|
||||
m_field->setValue( value );
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user