forked from bartvdbraak/blender
partial fix for [#23532]
- 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).
This commit is contained in:
parent
855b83caec
commit
ee1d2adc16
@ -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_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 {
|
||||
|
@ -156,6 +156,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
}
|
||||
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: ");
|
||||
@ -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);
|
||||
WM_operator_properties_sanitize(&ptr, 0);
|
||||
|
||||
|
||||
pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
|
||||
|
@ -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 */
|
||||
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);
|
||||
|
@ -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:
|
||||
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);
|
||||
@ -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);
|
||||
WM_operator_properties_sanitize(&opptr, val);
|
||||
WM_operator_properties_sanitize(&opptr, no_context);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -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_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){}
|
||||
|
Loading…
Reference in New Issue
Block a user