[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34590] trunk/blender/source/blender/ python/intern: workaround [#25845] Empty UI panels

Doug Hammond doughammond at hamsterfight.co.uk
Tue Feb 1 18:16:56 CET 2011


Campbell,

I must object strongly to what you've done here. Once again you've crippled
my addon (and perhaps others) at the drop of a hat, and again without giving
any prior notice or discussion on the issue.

Consider the design of an export/render addon:

1. Create an operator that exports the scene to file
2. Add an entry in file->export for that operator
3. USE that same operator to export the scene prior to rendering

Now that you've effectively disabled the scene export operator during
RenderEngine.render(), you've broken this addon design.
The only way I can possibly make the rendering work again is to duplicate a
whole load of code that forms the scene export operator into the render()
method, and this is clearly a bad idea.

Yours sincerely annoyed,
Doug Hammond.


On 1 February 2011 00:32, Campbell Barton <ideasman42 at gmail.com> wrote:

> Revision: 34590
>
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34590
> Author:   campbellbarton
> Date:     2011-02-01 00:32:50 +0000 (Tue, 01 Feb 2011)
> Log Message:
> -----------
> 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.
>
> Modified Paths:
> --------------
>    trunk/blender/source/blender/python/intern/bpy_operator.c
>    trunk/blender/source/blender/python/intern/bpy_rna.c
>    trunk/blender/source/blender/python/intern/bpy_rna.h
>
> Modified: trunk/blender/source/blender/python/intern/bpy_operator.c
> ===================================================================
> --- trunk/blender/source/blender/python/intern/bpy_operator.c   2011-01-31
> 23:54:51 UTC (rev 34589)
> +++ trunk/blender/source/blender/python/intern/bpy_operator.c   2011-02-01
> 00:32:50 UTC (rev 34590)
> @@ -138,6 +138,11 @@
>                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);
>
> Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
> ===================================================================
> --- trunk/blender/source/blender/python/intern/bpy_rna.c        2011-01-31
> 23:54:51 UTC (rev 34589)
> +++ trunk/blender/source/blender/python/intern/bpy_rna.c        2011-02-01
> 00:32:50 UTC (rev 34590)
> @@ -83,7 +83,19 @@
>        }
>        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 @@
>        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);
>
> Modified: trunk/blender/source/blender/python/intern/bpy_rna.h
> ===================================================================
> --- trunk/blender/source/blender/python/intern/bpy_rna.h        2011-01-31
> 23:54:51 UTC (rev 34589)
> +++ trunk/blender/source/blender/python/intern/bpy_rna.h        2011-02-01
> 00:32:50 UTC (rev 34590)
> @@ -108,4 +108,6 @@
>  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
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>


More information about the Bf-committers mailing list