Fix T46379: Bad behavior of bUnit_ToUnitAltName() with default units.

It would simply remove default units (in most case), cannot see any good reason for such behavior?
Might work in case default unit is the only one present, but breaks consistency (and it may not be
always obvious for user which unit it is). Comes from original patch from five years ago, rB7d8f0fce.

This will break keyboard-setting of values, e.g. '2m 33.4cm' would become '2 33.4cm',
totally useless and invalid entry!
This commit is contained in:
Bastien Montagne 2015-10-05 11:55:52 +02:00
parent 3d5622a208
commit 86aeb7df96
Notes: blender-bot 2023-02-14 08:58:01 +01:00
Referenced by issue #46379, Metric (Separate) units 'N Panel' edit panel doesn't strip spaces.
1 changed files with 1 additions and 2 deletions

View File

@ -730,11 +730,10 @@ void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int syste
bUnitCollection *usys = unit_get_system(system, type);
bUnitDef *unit;
bUnitDef *unit_def = unit_default(usys);
/* find and substitute all units */
for (unit = usys->units; unit->name; unit++) {
if (len_max > 0 && (unit->name_alt || unit == unit_def)) {
if (len_max > 0 && unit->name_alt) {
const char *found = unit_find_str(orig_str, unit->name_short);
if (found) {
int offset = (int)(found - orig_str);