[Bf-blender-cvs] [aed631fa477] master: Fix (unreported) wrong handling of some parameters combination in `bpy.data.user_map()`

Bastien Montagne noreply at git.blender.org
Mon Feb 18 17:17:05 CET 2019


Commit: aed631fa477984b6b0041ae047aa4994c566dc21
Author: Bastien Montagne
Date:   Mon Feb 18 17:14:40 2019 +0100
Branches: master
https://developer.blender.org/rBaed631fa477984b6b0041ae047aa4994c566dc21

Fix (unreported) wrong handling of some parameters combination in `bpy.data.user_map()`

Would add undesired keys...

===================================================================

M	source/blender/python/intern/bpy_rna_id_collection.c

===================================================================

diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index 72c808aa630..31b135fe933 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -225,7 +225,8 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
 
 	FOREACH_MAIN_ID_BEGIN(bmain, id)
 	{
-		if (val_types_bitmap != NULL) {
+		/* We cannot skip here in case we have some filter on key types... */
+		if (key_types_bitmap == NULL && 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. */
 			}
@@ -238,7 +239,12 @@ 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) {
+		if (!data_cb.is_subset &&
+		    /* We do not want to pre-add keys of flitered out types. */
+		    (key_types_bitmap == NULL || id_check_type(id, key_types_bitmap)) &&
+		    /* We do not want to pre-add keys when we have filter on value types, but not on key types. */
+		    (val_types_bitmap == NULL || key_types_bitmap != NULL))
+		{
 			PyObject *key = data_cb.py_id_key_lookup_only;
 			PyObject *set;
 
@@ -255,6 +261,10 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
 			}
 		}
 
+		if (val_types_bitmap != NULL && !id_check_type(id, val_types_bitmap)) {
+			continue;
+		}
+
 		data_cb.id_curr = id;
 		BKE_library_foreach_ID_link(NULL, id, foreach_libblock_id_user_map_callback, &data_cb, IDWALK_CB_NOP);



More information about the Bf-blender-cvs mailing list