partial fix for [#23532]
authorCampbell Barton <ideasman42@gmail.com>
Tue, 23 Nov 2010 12:05:35 +0000 (12:05 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 23 Nov 2010 12:05:35 +0000 (12:05 +0000)
- Python calling operators didn't run WM_operator_properties_sanitize() so enum functions called from python were given a NULL context.
- PROP_ENUM_NO_CONTEXT and PROP_NEVER_NULL used the same value in the enum (possible conflict).

source/blender/makesrna/RNA_types.h
source/blender/python/intern/bpy_operator.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_operators.c
source/blenderplayer/bad_level_call_stubs/stubs.c

index 5caae56010f2bb3892da7eeed279d0d0da6512c0..3fafae00ca68f5733967d9373545aefd37f8d9b9 100644 (file)
@@ -192,7 +192,7 @@ typedef enum PropertyFlag {
        PROP_RAW_ARRAY = 1<<14,
        PROP_FREE_POINTERS = 1<<15,
        PROP_DYNAMIC = 1<<17, /* for dynamic arrays, and retvals of type string */
        PROP_RAW_ARRAY = 1<<14,
        PROP_FREE_POINTERS = 1<<15,
        PROP_DYNAMIC = 1<<17, /* for dynamic arrays, and retvals of type string */
-       PROP_ENUM_NO_CONTEXT = 1<<18 /* for enum that shouldn't be contextual */
+       PROP_ENUM_NO_CONTEXT = 1<<24 /* for enum that shouldn't be contextual */
 } PropertyFlag;
 
 typedef struct CollectionPropertyIterator {
 } PropertyFlag;
 
 typedef struct CollectionPropertyIterator {
index e78e79fd6a825ebb341c6b7ef60da47775c400f3..c471f354fd4423115d8e289abea7c4d9ac0d74a4 100644 (file)
@@ -156,6 +156,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
        }
        else {
                WM_operator_properties_create_ptr(&ptr, ot);
        }
        else {
                WM_operator_properties_create_ptr(&ptr, ot);
+               WM_operator_properties_sanitize(&ptr, 0);
 
                if(kw && PyDict_Size(kw))
                        error_val= pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: ");
 
                if(kw && PyDict_Size(kw))
                        error_val= pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: ");
@@ -306,6 +307,7 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
 
        /* XXX - should call WM_operator_properties_free */
        WM_operator_properties_create_ptr(&ptr, ot);
 
        /* XXX - should call WM_operator_properties_free */
        WM_operator_properties_create_ptr(&ptr, ot);
+       WM_operator_properties_sanitize(&ptr, 0);
 
        
        pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
 
        
        pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
index 4ddeeb35c2b35b95908933a7b770607cb0960424..405db6309325262042c2c0638fb71754bf769cc9 100644 (file)
@@ -225,7 +225,7 @@ int                 WM_operator_name_call   (struct bContext *C, const char *opstring, int conte
 int                    WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports);
 
 void           WM_operator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *opstring); /* used for keymap and macro items */
 int                    WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports);
 
 void           WM_operator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *opstring); /* used for keymap and macro items */
-void           WM_operator_properties_sanitize(struct PointerRNA *ptr, int val); /* make props context sensitive or not */
+void           WM_operator_properties_sanitize(struct PointerRNA *ptr, const short no_context); /* make props context sensitive or not */
 void           WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring);
 void           WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot);
 void           WM_operator_properties_free(struct PointerRNA *ptr);
 void           WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring);
 void           WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot);
 void           WM_operator_properties_free(struct PointerRNA *ptr);
index 0578be949838b2827cdfb751e556b2eb29db769b..c83d3277610d613134c869764ad84d246e3bab08 100644 (file)
@@ -585,12 +585,12 @@ void WM_operator_properties_alloc(PointerRNA **ptr, IDProperty **properties, con
 
 }
 
 
 }
 
-void WM_operator_properties_sanitize(PointerRNA *ptr, int val)
+void WM_operator_properties_sanitize(PointerRNA *ptr, const short no_context)
 {
        RNA_STRUCT_BEGIN(ptr, prop) {
                switch(RNA_property_type(prop)) {
                case PROP_ENUM:
 {
        RNA_STRUCT_BEGIN(ptr, prop) {
                switch(RNA_property_type(prop)) {
                case PROP_ENUM:
-                       if (val)
+                       if (no_context)
                                RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT);
                        else
                                RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT);
                                RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT);
                        else
                                RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT);
@@ -602,7 +602,7 @@ void WM_operator_properties_sanitize(PointerRNA *ptr, int val)
                                /* recurse into operator properties */
                                if (RNA_struct_is_a(ptype, &RNA_OperatorProperties)) {
                                        PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
                                /* recurse into operator properties */
                                if (RNA_struct_is_a(ptype, &RNA_OperatorProperties)) {
                                        PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
-                                       WM_operator_properties_sanitize(&opptr, val);
+                                       WM_operator_properties_sanitize(&opptr, no_context);
                                }
                                break;
                        }
                                }
                                break;
                        }
index 949e85af1d2754d4c6d472d72ed963264046850f..23046734cdaab925ff61c4312d4917ad097b9a41 100644 (file)
@@ -363,6 +363,7 @@ int WM_operator_props_popup(struct bContext *C, struct wmOperator *op, struct wm
 void WM_operator_properties_free(struct PointerRNA *ptr){}
 void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring){}
 void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot){}
 void WM_operator_properties_free(struct PointerRNA *ptr){}
 void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring){}
 void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot){}
+void WM_operator_properties_sanitize(struct PointerRNA *ptr, const short no_context){};
 void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType*, void*), void *userdata){}
 void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType*, void*), void *userdata){}
 void WM_operator_bl_idname(char *to, const char *from){}
 void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType*, void*), void *userdata){}
 void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType*, void*), void *userdata){}
 void WM_operator_bl_idname(char *to, const char *from){}