Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-01-08 21:20:22 +0300
committerJacques Lucke <mail@jlucke.com>2019-01-08 21:20:56 +0300
commit12e9d52882e32d85c3890b73aa5a21aff9c787fc (patch)
tree9310070fd82ebe51f5de205183409b4ee2f427a6 /source/blender/blenkernel/intern/unit.c
parentae2af4692009fe2c3fc97783f6d69aaa7cac5123 (diff)
Fix T60327: Value input with adaptive imperial units not working properly
Diffstat (limited to 'source/blender/blenkernel/intern/unit.c')
-rw-r--r--source/blender/blenkernel/intern/unit.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 5527cb5d39a..7cac4c148ff 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -484,7 +484,7 @@ static bool is_valid_unit_collection(const bUnitCollection *usys)
return usys != NULL && usys->units[0].name != NULL;
}
-static const bUnitDef *get_preferred_unit_if_used(int type, PreferredUnits units)
+static const bUnitDef *get_preferred_display_unit_if_used(int type, PreferredUnits units)
{
const bUnitCollection *usys = unit_get_system(units.system, type);
if (!is_valid_unit_collection(usys)) return NULL;
@@ -525,7 +525,7 @@ static size_t unit_as_string_main(
usys = &buDummyCollection;
}
else {
- main_unit = get_preferred_unit_if_used(type, units);
+ main_unit = get_preferred_display_unit_if_used(type, units);
}
if (split && unit_should_be_split(type)) {
@@ -734,12 +734,12 @@ bool bUnit_ContainsUnit(const char *str, int system, int type)
return false;
}
-double bUnit_PreferredUnitScalar(const struct UnitSettings *settings, int type)
+double bUnit_PreferredInputUnitScalar(const struct UnitSettings *settings, int type)
{
PreferredUnits units = preferred_units_from_UnitSettings(settings);
- const bUnitDef *unit = get_preferred_unit_if_used(type, units);
- if (unit == NULL) return 1.0;
- else return unit->scalar;
+ const bUnitDef *unit = get_preferred_display_unit_if_used(type, units);
+ if (unit) return unit->scalar;
+ else return bUnit_BaseScalar(units.system, type);
}
/* make a copy of the string that replaces the units with numbers
@@ -905,7 +905,8 @@ double bUnit_ClosestScalar(double value, int system, int type)
double bUnit_BaseScalar(int system, int type)
{
const bUnitCollection *usys = unit_get_system(system, type);
- return unit_default(usys)->scalar;
+ if (usys) return unit_default(usys)->scalar;
+ else return 1.0;
}
/* external access */