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:
authorBastien Montagne <montagne29@wanadoo.fr>2019-02-18 18:39:12 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-02-18 19:16:33 +0300
commitb8ec2c95596fe9b9a0b4c3426640ba58eeeb2efb (patch)
tree2a2d0233b9311ba07e9b9dba2ffe48f0eebd9a23 /source/blender/python
parentb36f78abf402ba0c121be1a27248f239456139e3 (diff)
ID management: use FOREACH_MAIN_ID in some places.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.c72
1 files changed, 33 insertions, 39 deletions
diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index 584c21c5deb..5f18a64a8a2 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -159,6 +159,7 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
#else
Main *bmain = G_MAIN; /* XXX Ugly, but should work! */
#endif
+ ID *id;
PyObject *subset = NULL;
@@ -222,57 +223,51 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
data_cb.types_bitmap = key_types_bitmap;
- ListBase *lb_array[MAX_LIBARRAY];
- int lb_index;
- lb_index = set_listbasepointers(bmain, lb_array);
-
- while (lb_index--) {
- if (val_types_bitmap && lb_array[lb_index]->first) {
- if (!id_check_type(lb_array[lb_index]->first, val_types_bitmap)) {
- continue;
+ FOREACH_MAIN_ID_BEGIN(bmain, id)
+ {
+ if (val_types_bitmap != NULL) {
+ if (!id_check_type(id, val_types_bitmap)) {
+ break; /* Break iter on that type of IDs, continues with next ID type. */
}
}
- for (ID *id = lb_array[lb_index]->first; id; id = id->next) {
- /* One-time init, ID is just used as placeholder here, we abuse this in iterator callback
- * to avoid having to rebuild a complete bpyrna object each time for the key searching
- * (where only ID pointer value is used). */
- if (data_cb.py_id_key_lookup_only == NULL) {
- data_cb.py_id_key_lookup_only = pyrna_id_CreatePyObject(id);
- }
+ /* One-time init, ID is just used as placeholder here, we abuse this in iterator callback
+ * to avoid having to rebuild a complete bpyrna object each time for the key searching
+ * (where only ID pointer value is used). */
+ if (data_cb.py_id_key_lookup_only == NULL) {
+ data_cb.py_id_key_lookup_only = pyrna_id_CreatePyObject(id);
+ }
- if (!data_cb.is_subset) {
- PyObject *key = data_cb.py_id_key_lookup_only;
- PyObject *set;
-
- RNA_id_pointer_create(id, &((BPy_StructRNA *)key)->ptr);
-
- /* We have to insert the key now, otherwise ID unused would be missing from final dict... */
- if ((set = PyDict_GetItem(data_cb.user_map, key)) == NULL) {
- /* Cannot use our placeholder key here! */
- key = pyrna_id_CreatePyObject(id);
- set = PySet_New(NULL);
- PyDict_SetItem(data_cb.user_map, key, set);
- Py_DECREF(set);
- Py_DECREF(key);
- }
- }
+ if (!data_cb.is_subset) {
+ PyObject *key = data_cb.py_id_key_lookup_only;
+ PyObject *set;
- data_cb.id_curr = id;
- BKE_library_foreach_ID_link(NULL, id, foreach_libblock_id_user_map_callback, &data_cb, IDWALK_CB_NOP);
+ RNA_id_pointer_create(id, &((BPy_StructRNA *)key)->ptr);
- if (data_cb.py_id_curr) {
- Py_DECREF(data_cb.py_id_curr);
- data_cb.py_id_curr = NULL;
+ /* We have to insert the key now, otherwise ID unused would be missing from final dict... */
+ if ((set = PyDict_GetItem(data_cb.user_map, key)) == NULL) {
+ /* Cannot use our placeholder key here! */
+ key = pyrna_id_CreatePyObject(id);
+ set = PySet_New(NULL);
+ PyDict_SetItem(data_cb.user_map, key, set);
+ Py_DECREF(set);
+ Py_DECREF(key);
}
}
+
+ data_cb.id_curr = id;
+ BKE_library_foreach_ID_link(NULL, id, foreach_libblock_id_user_map_callback, &data_cb, IDWALK_CB_NOP);
+
+ if (data_cb.py_id_curr) {
+ Py_DECREF(data_cb.py_id_curr);
+ data_cb.py_id_curr = NULL;
+ }
}
+ FOREACH_MAIN_ID_END;
ret = data_cb.user_map;
-
error:
-
Py_XDECREF(data_cb.py_id_key_lookup_only);
if (key_types_bitmap) {
@@ -284,7 +279,6 @@ error:
}
return ret;
-
}
PyDoc_STRVAR(bpy_batch_remove_doc,