[Bf-blender-cvs] [86aeb7d] master: Fix T46379: Bad behavior of bUnit_ToUnitAltName() with default units.

Bastien Montagne noreply at git.blender.org
Mon Oct 5 12:02:26 CEST 2015


Commit: 86aeb7df961b994e87be57d85410de530b392f3e
Author: Bastien Montagne
Date:   Mon Oct 5 11:55:52 2015 +0200
Branches: master
https://developer.blender.org/rB86aeb7df961b994e87be57d85410de530b392f3e

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!

===================================================================

M	source/blender/blenkernel/intern/unit.c

===================================================================

diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 64d5614..ab8fbab 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -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);




More information about the Bf-blender-cvs mailing list