diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-05-03 12:37:24 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-05-03 12:51:49 +0300 |
commit | 66c74242bba3c2962ff5c3ddc02409171ec86dc3 (patch) | |
tree | 8902283a630a3aa24bf036e8e241b9b517808da6 /source/blender/blenkernel/intern/idprop.c | |
parent | bf0ac873ba13996756f0b553c41ea36097a6dec3 (diff) |
Make IDP_MergeGroup recursive
With this we also do not need IDP_MergeGroupValues anymore.
If this causes problems in the future we can always make recursion an
option (like overwrite is).
Diffstat (limited to 'source/blender/blenkernel/intern/idprop.c')
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 27f7cac2a8e..a3bd15252cb 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -600,32 +600,8 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) } /** - * Same as IDP_MergeGroup but recursively - */ -void IDP_MergeGroupValues(IDProperty *dest, IDProperty *src) -{ - IDProperty *prop; - - BLI_assert(dest->type == IDP_GROUP); - BLI_assert(src->type == IDP_GROUP); - - for (prop = src->data.group.first; prop; prop = prop->next) { - if (prop->type == IDP_GROUP) { - IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name); - - if (prop_exist != NULL) { - IDP_MergeGroupValues(prop_exist, prop); - continue; - } - } - - IDProperty *copy = IDP_CopyProperty(prop); - IDP_ReplaceInGroup(dest, copy); - } -} - -/** * If a property is missing in \a dest, add it. + * Do it recursively. */ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite) { @@ -636,13 +612,29 @@ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overw if (do_overwrite) { for (prop = src->data.group.first; prop; prop = prop->next) { + if (prop->type == IDP_GROUP) { + IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name); + + if (prop_exist != NULL) { + IDP_MergeGroup(prop_exist, prop, do_overwrite); + continue; + } + } + IDProperty *copy = IDP_CopyProperty(prop); IDP_ReplaceInGroup(dest, copy); } } else { for (prop = src->data.group.first; prop; prop = prop->next) { - if (IDP_GetPropertyFromGroup(dest, prop->name) == NULL) { + IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name); + if (prop_exist != NULL) { + if (prop->type == IDP_GROUP) { + IDP_MergeGroup(prop_exist, prop, do_overwrite); + continue; + } + } + else { IDProperty *copy = IDP_CopyProperty(prop); dest->len++; BLI_addtail(&dest->data.group, copy); |