diff options
author | Joseph Eagar <joeedh@gmail.com> | 2006-11-17 11:19:58 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2006-11-17 11:19:58 +0300 |
commit | ab141e143947c9691fb747ad8d9fd8842c4dacde (patch) | |
tree | f0be2678aee5e5ba2bef3175e94e5aa64477d8d3 /source/blender/blenkernel/intern | |
parent | 80f7ea96c83d8ae442b961906dc838ec03f06f00 (diff) |
=ID Properties Python Update=
IDProperties now have a sanity check to prevent different ID properties
in the same group from having the same name. The appropriate code has been
added to the python bindings to catch this and raise an error.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 66feaffadb7..6a748a295b9 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -14,6 +14,8 @@ #include <stdlib.h> #include <string.h> +#define BSTR_EQ(a, b) (*(a) == *(b) && !strcmp(a, b)) + /* IDPropertyTemplate is a union in DNA_ID.h */ static char idp_size_table[] = { 0, /*strings don't have fixed sizes :)*/ @@ -135,10 +137,19 @@ void IDP_UnlinkID(IDProperty *prop) } /*-------- Group Functions -------*/ -void IDP_AddToGroup(IDProperty *group, IDProperty *prop) +/*returns 0 if an id property with the same name exists and it failed, + or 1 if it succeeded in adding to the group.*/ +int IDP_AddToGroup(IDProperty *group, IDProperty *prop) { + IDProperty *loop; + for (loop=group->data.group.first; loop; loop=loop->next) { + if (BSTR_EQ(loop->name, prop->name)) return 0; + } + group->len++; BLI_addtail(&group->data.group, prop); + + return 1; } void IDP_RemFromGroup(IDProperty *group, IDProperty *prop) |