diff options
author | Julian Eisel <julian@blender.org> | 2020-06-05 14:09:31 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-06-05 14:09:31 +0300 |
commit | 920a58d9b6d667894cf166cbbd25e4c2fbd238ea (patch) | |
tree | 7ca5a9da640753b5e070c439ac3bdd14dfad92cf /source/blender/blenkernel/intern/idprop.c | |
parent | c94b6209861ca7cc3985b53474feed7d94c0221a (diff) | |
parent | a1d55bdd530390e58c51abe9707b8d3b0ae3e861 (diff) |
Merge branch 'master' into wm-drag-drop-rewritewm-drag-drop-rewrite
Diffstat (limited to 'source/blender/blenkernel/intern/idprop.c')
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 554b8d93db3..669539ca574 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -800,7 +800,7 @@ void IDP_RelinkProperty(struct IDProperty *prop) switch (prop->type) { case IDP_GROUP: { - for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) { + LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) { IDP_RelinkProperty(loop); } break; @@ -1130,4 +1130,45 @@ void IDP_Reset(IDProperty *prop, const IDProperty *reference) } } +/** + * Loop through all ID properties in hierarchy of given \a id_property_root included. + * + * \note Container types (groups and arrays) are processed after applying the callback on them. + * + * \param type_filter: If not 0, only apply callback on properties of matching types, see + * IDP_TYPE_FILTER_ enum in DNA_ID.h. + */ +void IDP_foreach_property(IDProperty *id_property_root, + const int type_filter, + IDPForeachPropertyCallback callback, + void *user_data) +{ + if (!id_property_root) { + return; + } + + if (type_filter == 0 || (1 << id_property_root->type) & type_filter) { + callback(id_property_root, user_data); + } + + /* Recursive call into container types of ID properties. */ + switch (id_property_root->type) { + case IDP_GROUP: { + LISTBASE_FOREACH (IDProperty *, loop, &id_property_root->data.group) { + IDP_foreach_property(loop, type_filter, callback, user_data); + } + break; + } + case IDP_IDPARRAY: { + IDProperty *loop = IDP_Array(id_property_root); + for (int i = 0; i < id_property_root->len; i++) { + IDP_foreach_property(&loop[i], type_filter, callback, user_data); + } + break; + } + default: + break; /* Nothing to do here with other types of IDProperties... */ + } +} + /** \} */ |