Fix T50063: Editing driver's expression eliminates "Zero" number

Disables trimming of trailing zeros in case button contains an expression.
This commit is contained in:
Julian Eisel 2016-11-18 13:37:04 +01:00
parent fffb1a4cfb
commit 3fb11061ba
Notes: blender-bot 2023-10-12 12:49:04 +02:00
Referenced by issue #50063, Editing driver's expression eliminates "Zero" number
2 changed files with 8 additions and 2 deletions

View File

@ -99,6 +99,10 @@ void ui_but_anim_flag(uiBut *but, float cfra)
}
}
/**
* \a str can be NULL to only perform check if \a but has an expression at all.
* \return if button has an expression.
*/
bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
{
FCurve *fcu;
@ -111,7 +115,9 @@ bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
driver = fcu->driver;
if (driver && driver->type == DRIVER_TYPE_PYTHON) {
BLI_strncpy(str, driver->expression, maxlen);
if (str) {
BLI_strncpy(str, driver->expression, maxlen);
}
return true;
}
}

View File

@ -3067,7 +3067,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
data->str = ui_but_string_get_dynamic(but, &data->maxlen);
}
if (ui_but_is_float(but) && !ui_but_is_unit(but)) {
if (ui_but_is_float(but) && !ui_but_is_unit(but) && !ui_but_anim_expression_get(but, NULL, 0)) {
BLI_str_rstrip_float_zero(data->str, '\0');
}