disable the readonly state while rna property callbacks run.

This commit is contained in:
Campbell Barton 2011-06-07 16:08:49 +00:00
parent 53939ee4e9
commit e44ae2c2a9
3 changed files with 19 additions and 0 deletions

@ -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)

@ -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);

@ -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);