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>2016-09-13 14:22:03 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-09-13 14:23:03 +0300
commitf38f7874488de876410e1bb4acf67a4629ba2b82 (patch)
tree4c19fa73039b544e1a0ebdf9abb32b50fc1cb903 /source/blender/python/intern/bpy_rna_id_collection.c
parentd82710cc02f9a6c82b8a738c0a5d493b97533b93 (diff)
Fix bpy.data.user_map() ignoring unused datablocks.
Should be backported to 2.78. Found by Sybren here in studio, thanks!
Diffstat (limited to 'source/blender/python/intern/bpy_rna_id_collection.c')
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index 31189ba4dee..3e50e79c19e 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -233,8 +233,26 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
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);
+ }
+ }
+
data_cb.id_curr = id;
BKE_library_foreach_ID_link(id, foreach_libblock_id_user_map_callback, &data_cb, IDWALK_NOP);
+
if (data_cb.py_id_curr) {
Py_DECREF(data_cb.py_id_curr);
data_cb.py_id_curr = NULL;