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:
authorJoseph Eagar <joeedh@gmail.com>2007-07-10 00:42:14 +0400
committerJoseph Eagar <joeedh@gmail.com>2007-07-10 00:42:14 +0400
commit4f01085709908e5626c735b01d6c2202236f41e6 (patch)
tree6a6213a149e55e68cc5bd5832f71bc921d884b83 /source/blender/blenkernel/intern/idprop.c
parentdfa6e0b8d66a6335e07bfdcba2bd1fc96d2a846b (diff)
=ID Property update=
ID Properties weren't being duplicated (by shift-D or any of the other duplication functions). So now ID properties are duplicated in the main copy_libblock function, which (as far as I can check) covers all ID-contained ID properties. I also updated the constraint system to copy pyconstraint ID properties on shift-D. This would probably be a good thing to add to the stable branch, btw.
Diffstat (limited to 'source/blender/blenkernel/intern/idprop.c')
-rw-r--r--source/blender/blenkernel/intern/idprop.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index bb4c66da0b1..bf2a3aae11a 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -104,6 +104,31 @@ void IDP_ResizeArray(IDProperty *prop, int newlen)
MEM_freeN(prop->data.pointer);
}
+
+ static IDProperty *idp_generic_copy(IDProperty *prop)
+ {
+ IDProperty *newp = MEM_callocN(sizeof(IDProperty), "IDProperty array dup");
+
+ strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
+ newp->type = prop->type;
+ newp->flag = prop->flag;
+ newp->data.val = prop->data.val;
+
+ return newp;
+ }
+
+IDProperty *IDP_CopyArray(IDProperty *prop)
+{
+ IDProperty *newp = idp_generic_copy(prop);
+
+ if (prop->data.pointer) newp->data.pointer = MEM_dupallocN(prop->data.pointer);
+ newp->len = prop->len;
+ newp->subtype = prop->subtype;
+ newp->totallen = prop->totallen;
+
+ return newp;
+}
+
/*taken from readfile.c*/
#define SWITCH_LONGINT(a) { \
char s_i, *p_i; \
@@ -116,6 +141,19 @@ void IDP_ResizeArray(IDProperty *prop, int newlen)
/* ---------- String Type ------------ */
+IDProperty *IDP_CopyString(IDProperty *prop)
+{
+ IDProperty *newp = idp_generic_copy(prop);
+
+ if (prop->data.pointer) newp->data.pointer = MEM_dupallocN(prop->data.pointer);
+ newp->len = prop->len;
+ newp->subtype = prop->subtype;
+ newp->totallen = prop->totallen;
+
+ return newp;
+}
+
+
void IDP_AssignString(IDProperty *prop, char *st)
{
int stlen;
@@ -154,7 +192,7 @@ void IDP_FreeString(IDProperty *prop)
}
-/*-------- ID Type -------*/
+/*-------- ID Type, not in use yet -------*/
void IDP_LinkID(IDProperty *prop, ID *id)
{
@@ -171,6 +209,17 @@ void IDP_UnlinkID(IDProperty *prop)
/*-------- Group Functions -------*/
/*checks if a property with the same name as prop exists, and if so replaces it.*/
+IDProperty *IDP_CopyGroup(IDProperty *prop)
+{
+ IDProperty *newp = idp_generic_copy(prop), *link;
+
+ for (link=prop->data.group.first; link; link=link->next) {
+ BLI_addtail(&newp->data.group, IDP_CopyProperty(link));
+ }
+
+ return newp;
+}
+
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
{
IDProperty *loop;
@@ -282,6 +331,15 @@ void IDP_FreeGroup(IDProperty *prop)
/*-------- Main Functions --------*/
+IDProperty *IDP_CopyProperty(IDProperty *prop)
+{
+ switch (prop->type) {
+ case IDP_GROUP: return IDP_CopyGroup(prop);
+ case IDP_STRING: return IDP_CopyString(prop);
+ case IDP_ARRAY: return IDP_CopyArray(prop);
+ default: return idp_generic_copy(prop);
+ }
+}
IDProperty *IDP_GetProperties(ID *id, int create_if_needed)
{