Avoid -fsanitize=implicit-signed-integer-truncation in weld::MetricSpinButton
Both of Draw's "Insert - Snap Guide..." and "Shape - Duplicate..." dialogs have MetricSpinButtons with ranges set programmatically in the dialogs' ctors. Computing the ranges' min and max values was done via SetMetricValue, which does any necessary unit conversions and then sets the MetricSpinButton's current value, which is then read back out in the dialog ctors (again, doing any necessary unit conversions) and finally set as the min or max range value. However, setting a MetricSpinButton's current value clamps it to the min and max range values that are currently in effect (i.e., before they have been set programmatically), so the corresponding .ui files specified very large initial values for those. Large enough so that any actually set current values will not artificially be clamped, but also so large that weld::MetricSpinButton::ConvertValue, which indirectly gets called during the above computations and converts from sal_Int64 to int, would produce Clang -fsanitize=implicit-signed-integer-truncation warnings (e.g., "implicit conversion from type 'sal_Int64' (aka 'long') of value -56692913386 (64-bit, signed) to type 'int' changed the value to -858338538 (32-bit, signed)" from within the CopyDlg ctor). So don't use SetMetricValue to compute the min/max range values. That way, the MetricSpinButton's current value is not set before the computed min/max range values are actually set, so the .ui file doesn't need to contain any static min/max range values. Also, both dialogs call SetFieldUnit, which also sets the MetricSpinButtons' increment values, so those don't need to be set statically in the .ui files, either. Change-Id: I191cfc3837278530e0c3a87e00708c4c76a76361 Reviewed-on: https://gerrit.libreoffice.org/67734 Tested-by: Jenkins Reviewed-by:Caolán McNamara <caolanm@redhat.com> Tested-by:
Caolán McNamara <caolanm@redhat.com>
Showing
Please
register
or
sign in
to comment