diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-22 14:49:35 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-22 14:49:35 +0400 |
commit | ebe63b664baa2f4e65643a2535766e5babf9c8a7 (patch) | |
tree | 7b0303d4f8311bd34483c0c7999c4c29b40f2263 /source/blender/editors | |
parent | cac4fde224f3dfb2831779df7b61f819a3564e2d (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')
8 files changed, 12 insertions, 11 deletions
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index 383e0bac796..d18a3c320f7 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -118,7 +118,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) PropertyRNA *nameprop= RNA_struct_name_property(ptr.type); if (nameprop) { /* this gets a string which will need to be freed */ - structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0); + structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL); free_structname= 1; } else 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); } } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 2f423a361b8..be6c89eb37d 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1221,7 +1221,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s iconid= ui_id_icon_get((bContext*)C, id, 1); } else { - name= RNA_struct_name_get_alloc(&itemptr, NULL, 0); + name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */ iconid = 0; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index c6bc0f58b5b..34f9849fac7 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2085,7 +2085,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe if(icon == ICON_NONE || icon == ICON_DOT) icon= 0; - namebuf= RNA_struct_name_get_alloc(itemptr, NULL, 0); + namebuf= RNA_struct_name_get_alloc(itemptr, NULL, 0, NULL); name= (namebuf)? namebuf: ""; /* hardcoded types */ @@ -2270,7 +2270,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * if(found) { /* create button */ - name= RNA_struct_name_get_alloc(&itemptr, NULL, 0); + name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); icon= list_item_icon_get(C, &itemptr, rnaicon, 0); uiItemL(row, (name)? name: "", icon); diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 4a2860335fe..309c5cfc218 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -925,7 +925,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) if(ptr->data) { icon= RNA_struct_ui_icon(ptr->type); - name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf)); + name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); if(name) { if(!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene) diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 75b3eb950a5..3cf4de992e5 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -169,7 +169,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) if(!prop) return OPERATOR_CANCELLED; - str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0); + str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL); /* useful yet irritating feature, Shift+Click to open the file * Alt+Click to browse a folder in the OS's browser */ diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 1d1abf80fe4..30a7abd3c0b 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1021,7 +1021,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle /* tsenext= TREESTORE(temnext); */ /* UNUSED */ nextptr= &temnext->rnaptr; - name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf)); + name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); if(name) { /* if possible, use name as a key in the path */ diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index dda103b971b..925c4571a66 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -972,7 +972,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } else if(type == TSE_RNA_STRUCT) { /* struct */ - te->name= RNA_struct_name_get_alloc(ptr, NULL, 0); + te->name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); if(te->name) te->flag |= TE_FREE_NAME; |