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-09 12:39:31 +0300
committerJacques Lucke <mail@jlucke.com>2019-01-09 12:40:05 +0300
commit22ddd573638582ad5213bb4a7ff23ccae50dd285 (patch)
tree45f521fa73ae8a4062113c297e3e0703a549c2ca /source/blender/blenkernel
parent06d1c2f7373d3b506675dd671661be26bc50704f (diff)
Fix T60338: Allow user to input units of another system
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_unit.h2
-rw-r--r--source/blender/blenkernel/intern/unit.c14
2 files changed, 9 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index b19cc340bbf..81da3bea3d6 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -43,7 +43,7 @@ size_t bUnit_AsString2(char *str, int len_max, double value, int prec, int type,
bool bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double scale_pref, int system, int type);
/* return true if the string contains any valid unit for the given type */
-bool bUnit_ContainsUnit(const char *str, int system, int type);
+bool bUnit_ContainsUnit(const char *str, int type);
/* if user does not specify a unit, multiply with this value */
double bUnit_PreferredInputUnitScalar(const struct UnitSettings *settings, int type);
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 7cac4c148ff..3fd47b515f6 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -721,14 +721,16 @@ static const bUnitDef *unit_detect_from_str(const bUnitCollection *usys, const c
return unit;
}
-bool bUnit_ContainsUnit(const char *str, int system, int type)
+bool bUnit_ContainsUnit(const char *str, int type)
{
- const bUnitCollection *usys = unit_get_system(system, type);
- if (!is_valid_unit_collection(usys)) return false;
+ for (int system = 0; system < UNIT_SYSTEM_TOT; system++) {
+ const bUnitCollection *usys = unit_get_system(system, type);
+ if (!is_valid_unit_collection(usys)) continue;
- for (int i = 0; i < usys->length; i++) {
- if (unit_find(str, usys->units + i)) {
- return true;
+ for (int i = 0; i < usys->length; i++) {
+ if (unit_find(str, usys->units + i)) {
+ return true;
+ }
}
}
return false;