Bring new IDP_MergeGroup() on par with other copying logic.

We now have to support more complex copying types, which are controlled
by flags, so all copying logic will need to take those at some point (at
least, all potentially dealing with IDs).
This commit is contained in:
Bastien Montagne 2017-08-15 16:42:20 +02:00
parent cf2f6a986c
commit c8b3f13c9e
2 changed files with 15 additions and 5 deletions

View File

@ -91,6 +91,7 @@ void IDP_ReplaceGroupInGroup(struct IDProperty *dest, const struct IDProperty *s
void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
void IDP_ReplaceInGroup_ex(struct IDProperty *group, struct IDProperty *prop, struct IDProperty *prop_exist);
void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite) ATTR_NONNULL();
void IDP_MergeGroup_ex(IDProperty *dest, const IDProperty *src, const bool do_overwrite, const int flag) ATTR_NONNULL();
bool IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
bool IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
struct IDProperty *pnew) ATTR_NONNULL(1 /* group */, 3 /* pnew */);

View File

@ -605,7 +605,7 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
* 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)
void IDP_MergeGroup_ex(IDProperty *dest, const IDProperty *src, const bool do_overwrite, const int flag)
{
IDProperty *prop;
@ -618,12 +618,12 @@ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overw
IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name);
if (prop_exist != NULL) {
IDP_MergeGroup(prop_exist, prop, do_overwrite);
IDP_MergeGroup_ex(prop_exist, prop, do_overwrite, flag);
continue;
}
}
IDProperty *copy = IDP_CopyProperty(prop);
IDProperty *copy = IDP_CopyProperty_ex(prop, flag);
IDP_ReplaceInGroup(dest, copy);
}
}
@ -632,12 +632,12 @@ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overw
IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name);
if (prop_exist != NULL) {
if (prop->type == IDP_GROUP) {
IDP_MergeGroup(prop_exist, prop, do_overwrite);
IDP_MergeGroup_ex(prop_exist, prop, do_overwrite, flag);
continue;
}
}
else {
IDProperty *copy = IDP_CopyProperty(prop);
IDProperty *copy = IDP_CopyProperty_ex(prop, flag);
dest->len++;
BLI_addtail(&dest->data.group, copy);
}
@ -645,6 +645,15 @@ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overw
}
}
/**
* 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)
{
IDP_MergeGroup_ex(dest, src, do_overwrite, 0);
}
/**
* This function has a sanity check to make sure ID properties with the same name don't
* get added to the group.