From aed631fa477984b6b0041ae047aa4994c566dc21 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 18 Feb 2019 17:14:40 +0100 Subject: Fix (unreported) wrong handling of some parameters combination in `bpy.data.user_map()` Would add undesired keys... --- source/blender/python/intern/bpy_rna_id_collection.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source/blender/python') 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); -- cgit v1.2.3