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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-02-01 03:32:50 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-01 03:32:50 +0300
commit11d61383fa446b53794c9800ba24f4ecc8a8bcfd (patch)
tree16a888825ad61e85931865aabf9ffb054cd4b93d
parente8f7f42c1d8421d8112d9f9c67b8cb4ed231877e (diff)
workaround [#25845] Empty UI panels
- now writing to RNA is disabled when inside render() call. - disallow calling operators when writes are disabled. Rendering runs in a thread so running operators from the thread is not safe unless rendering becomes a blocking operator again.
-rw-r--r--source/blender/python/intern/bpy_operator.c5
-rw-r--r--source/blender/python/intern/bpy_rna.c15
-rw-r--r--source/blender/python/intern/bpy_rna.h2
3 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index d5446b11349..2130dd60f12 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -138,6 +138,11 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
+ if(!pyrna_write_check()) {
+ PyErr_Format(PyExc_SystemError, "Calling operator \"bpy.ops.%s\" error, can't modify blend data in this state (drawing/rendering)", opname);
+ return NULL;
+ }
+
if(context_str) {
if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
char *enum_str= BPy_enum_as_string(operator_context_items);
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index b8a448106f9..41aa0661fd5 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -83,7 +83,19 @@ static int rna_id_write_error(PointerRNA *ptr, PyObject *key)
}
return FALSE;
}
+#endif // USE_PEDANTIC_WRITE
+
+#ifdef USE_PEDANTIC_WRITE
+int pyrna_write_check(void)
+{
+ return !rna_disallow_writes;
+}
+#else // USE_PEDANTIC_WRITE
+int pyrna_write_check(void)
+{
+ return TRUE;
+}
#endif // USE_PEDANTIC_WRITE
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self);
@@ -5324,8 +5336,9 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
PyGILState_STATE gilstate;
#ifdef USE_PEDANTIC_WRITE
+ const char *func_id= RNA_function_identifier(func);
/* testing, for correctness, not operator and not draw function */
- const short is_readonly= strstr("draw", RNA_function_identifier(func)) || !RNA_struct_is_a(ptr->type, &RNA_Operator);
+ const short is_readonly= strstr("draw", func_id) || strstr("render", func_id) || !RNA_struct_is_a(ptr->type, &RNA_Operator);
#endif
py_class= RNA_struct_py_type_get(ptr->type);
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index 77b602b6f83..854f077abed 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -108,4 +108,6 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
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);
+
#endif