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:
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 149497c85fb..c1c22afcf75 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -748,12 +748,12 @@ void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
srna->blender_type= blender_type;
}
-char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen)
+char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
{
PropertyRNA *nameprop;
if(ptr->data && (nameprop = RNA_struct_name_property(ptr->type)))
- return RNA_property_string_get_alloc(ptr, nameprop, fixedbuf, fixedlen);
+ return RNA_property_string_get_alloc(ptr, nameprop, fixedbuf, fixedlen, r_len);
return NULL;
}
@@ -2276,7 +2276,8 @@ void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
strcpy(value, sprop->defaultvalue);
}
-char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen)
+char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop,
+ char *fixedbuf, int fixedlen, int *r_len)
{
char *buf;
int length;
@@ -2301,6 +2302,10 @@ char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fi
BLI_assert(buf[length] == '\0');
#endif
+ if (r_len) {
+ *r_len= length;
+ }
+
return buf;
}
@@ -2836,15 +2841,17 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co
PropertyRNA *nameprop;
char name[256], *nameptr;
int found= 0;
+ int keylen= strlen(key);
+ int namelen;
RNA_property_collection_begin(ptr, prop, &iter);
for(; iter.valid; RNA_property_collection_next(&iter)) {
if(iter.ptr.data && iter.ptr.type->nameproperty) {
nameprop= iter.ptr.type->nameproperty;
- nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name));
+ nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name), &namelen);
- if(strcmp(nameptr, key) == 0) {
+ if((keylen == namelen) && (strcmp(nameptr, key) == 0)) {
*r_ptr= iter.ptr;
found= 1;
}
@@ -4254,7 +4261,7 @@ char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, in
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
if(prop) {
- return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen);
+ return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen, NULL); /* TODO, pass length */
}
else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
@@ -5442,7 +5449,7 @@ int RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, i
}
case PROP_STRING:
{
- char *value= RNA_property_string_get_alloc(fromptr, prop, NULL, 0);
+ char *value= RNA_property_string_get_alloc(fromptr, prop, NULL, 0, NULL);
RNA_property_string_set(ptr, prop, value);
MEM_freeN(value);
return 1;