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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-02-22 11:27:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-02-22 11:27:45 +0300
commite31d0198e67b28d925ee8164efe8971dba8721b1 (patch)
treeb68a822cb21e44b6ccc67cbf9833cd13a3c6d321 /source
parent2bfee787a6b2a8884344ef4ef460a4f83da8262d (diff)
exclude self references from the ID search list when PROP_ID_SELF_CHECK is set, also raise an error from python if this is attempted
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_templates.c13
-rw-r--r--source/blender/makesrna/intern/rna_access.c6
-rw-r--r--source/blender/python/intern/bpy_rna.c3
3 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 313e7b67183..0c44b15296a 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -157,16 +157,19 @@ static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSea
{
TemplateID *template= (TemplateID*)arg_template;
ListBase *lb= template->idlb;
- ID *id;
+ ID *id, *id_from= template->ptr.id.data;
int iconid;
+ int flag= RNA_property_flag(template->prop);
/* ID listbase */
for(id= lb->first; id; id= id->next) {
- if(BLI_strcasestr(id->name+2, str)) {
- iconid= ui_id_icon_get((bContext*)C, id, 0);
+ if(!((flag & PROP_ID_SELF_CHECK) && id == id_from)) {
+ if(BLI_strcasestr(id->name+2, str)) {
+ iconid= ui_id_icon_get((bContext*)C, id, 0);
- if(!uiSearchItemAdd(items, id->name+2, id, iconid))
- break;
+ if(!uiSearchItemAdd(items, id->name+2, id, iconid))
+ break;
+ }
}
}
}
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 81e34dad7c0..6cbad6b9dcf 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1937,8 +1937,12 @@ void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr
else {
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
- if(pprop->set && !((prop->flag & PROP_NEVER_NULL) && ptr_value.data == NULL))
+ if( pprop->set &&
+ !((prop->flag & PROP_NEVER_NULL) && ptr_value.data == NULL) &&
+ !((prop->flag & PROP_ID_SELF_CHECK) && ptr->id.data == ptr_value.id.data)
+ ) {
pprop->set(ptr, ptr_value);
+ }
}
}
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 691010ade0d..29c262d5815 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -886,6 +886,9 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
} else if((flag & PROP_NEVER_NULL) && value == Py_None) {
PyErr_Format(PyExc_TypeError, "%.200s does not support a 'None' assignment %.200s type", error_prefix, RNA_struct_identifier(ptype));
return -1;
+ } else if(value != Py_None && ((flag & PROP_ID_SELF_CHECK) && ptr->id.data == ((BPy_StructRNA*)value)->ptr.id.data)) {
+ PyErr_Format(PyExc_TypeError, "%.200s ID type does not support assignment to its self", error_prefix);
+ return -1;
} else {
BPy_StructRNA *param= (BPy_StructRNA*)value;
int raise_error= FALSE;