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:
authorCampbell Barton <ideasman42@gmail.com>2011-10-22 14:49:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-22 14:49:35 +0400
commitebe63b664baa2f4e65643a2535766e5babf9c8a7 (patch)
tree7b0303d4f8311bd34483c0c7999c4c29b40f2263 /source/blender/editors/interface/interface.c
parentcac4fde224f3dfb2831779df7b61f819a3564e2d (diff)
py api - added PyC_UnicodeFromByteAndSize() to match PyUnicode_FromStringAndSize()
also made RNA_property_string_get_alloc() return the length of the new string to avoid having to run strlen on it after.
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index a12d297bbb1..b7b572e7217 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1593,17 +1593,18 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
PropertyType type;
char *buf= NULL;
+ int buf_len;
type= RNA_property_type(but->rnaprop);
if(type == PROP_STRING) {
/* RNA string */
- buf= RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen);
+ buf= RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len);
}
else if(type == PROP_POINTER) {
/* RNA pointer */
PointerRNA ptr= RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
- buf= RNA_struct_name_get_alloc(&ptr, str, maxlen);
+ buf= RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len);
}
if(!buf) {
@@ -1611,7 +1612,7 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
}
else if(buf && buf != str) {
/* string was too long, we have to truncate */
- BLI_strncpy(str, buf, maxlen);
+ memcpy(str, buf, MIN2(maxlen, buf_len+1));
MEM_freeN(buf);
}
}