From e44ae2c2a982cd3c98e5544bfe0a241f0b063485 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Jun 2011 16:08:49 +0000 Subject: [PATCH] disable the readonly state while rna property callbacks run. --- source/blender/python/intern/bpy_props.c | 9 +++++++++ source/blender/python/intern/bpy_rna.c | 9 +++++++++ source/blender/python/intern/bpy_rna.h | 1 + 3 files changed, 19 insertions(+) diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index b8912a1d4a7..8ed4e41de3e 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -185,9 +185,14 @@ void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struct Prope PyObject *args; PyObject *self; PyObject *ret; + const int is_write_ok= pyrna_write_check(); BLI_assert(py_data != NULL); + if(!is_write_ok) { + pyrna_write_set(TRUE); + } + bpy_context_set(C, &gilstate); py_func= py_data[BPY_DATA_CB_SLOT_UPDATE]; @@ -216,6 +221,10 @@ void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struct Prope } bpy_context_clear(C, &gilstate); + + if(!is_write_ok) { + pyrna_write_set(FALSE); + } } static int bpy_prop_callback_check(PyObject *py_func, int argcount) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4fe13bc6818..38cc3edd8f6 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -323,11 +323,20 @@ int pyrna_write_check(void) { return !rna_disallow_writes; } + +void pyrna_write_set(int val) +{ + rna_disallow_writes= !val; +} #else // USE_PEDANTIC_WRITE int pyrna_write_check(void) { return TRUE; } +void pyrna_write_set(int UNUSED(val)) +{ + /* nothing */ +} #endif // USE_PEDANTIC_WRITE static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self); diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index dbb5fc2feb7..5db352af53d 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -183,6 +183,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop); int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value); int pyrna_write_check(void); +void pyrna_write_set(int val); int pyrna_struct_validity_check(BPy_StructRNA *pysrna); int pyrna_prop_validity_check(BPy_PropertyRNA *self);