Fix: Operator properties don't undo when owner is collection
For collection export, we need operator properties to not assume they are owned by the window manager. Pull Request: https://projects.blender.org/blender/blender/pulls/118855
This commit is contained in:
parent
f3505f12d2
commit
bef3a7b978
|
@ -616,6 +616,13 @@ static bool rna_Operator_has_reports_get(PointerRNA *ptr)
|
|||
return (op->reports && op->reports->list.first);
|
||||
}
|
||||
|
||||
static PointerRNA rna_Operator_layout_get(PointerRNA *ptr)
|
||||
{
|
||||
/* Operator owner is not inherited, layout is owned by WM. */
|
||||
wmOperator *op = (wmOperator *)ptr->data;
|
||||
return RNA_pointer_create(nullptr, &RNA_UILayout, op->layout);
|
||||
}
|
||||
|
||||
static PointerRNA rna_Operator_options_get(PointerRNA *ptr)
|
||||
{
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_OperatorOptions, ptr->data);
|
||||
|
@ -627,6 +634,7 @@ static PointerRNA rna_Operator_properties_get(PointerRNA *ptr)
|
|||
|
||||
PointerRNA result;
|
||||
WM_operator_properties_create_ptr(&result, op->type);
|
||||
result.owner_id = (ptr->owner_id) ? ptr->owner_id : result.owner_id;
|
||||
result.data = op->properties;
|
||||
return result;
|
||||
}
|
||||
|
@ -638,6 +646,7 @@ static PointerRNA rna_OperatorMacro_properties_get(PointerRNA *ptr)
|
|||
|
||||
PointerRNA result;
|
||||
WM_operator_properties_create_ptr(&result, ot);
|
||||
result.owner_id = (ptr->owner_id) ? ptr->owner_id : result.owner_id;
|
||||
result.data = otmacro->properties;
|
||||
return result;
|
||||
}
|
||||
|
@ -1336,7 +1345,8 @@ static int rna_operator_exec_cb(bContext *C, wmOperator *op)
|
|||
void *ret;
|
||||
int result;
|
||||
|
||||
PointerRNA opr = RNA_pointer_create(nullptr, op->type->rna_ext.srna, op);
|
||||
ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
|
||||
PointerRNA opr = RNA_pointer_create(owner_id, op->type->rna_ext.srna, op);
|
||||
func = &rna_Operator_execute_func; /* RNA_struct_find_function(&opr, "execute"); */
|
||||
|
||||
RNA_parameter_list_create(&list, &opr, func);
|
||||
|
@ -1366,7 +1376,8 @@ static bool rna_operator_check_cb(bContext *C, wmOperator *op)
|
|||
void *ret;
|
||||
bool result;
|
||||
|
||||
PointerRNA opr = RNA_pointer_create(nullptr, op->type->rna_ext.srna, op);
|
||||
ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
|
||||
PointerRNA opr = RNA_pointer_create(owner_id, op->type->rna_ext.srna, op);
|
||||
func = &rna_Operator_check_func; /* RNA_struct_find_function(&opr, "check"); */
|
||||
|
||||
RNA_parameter_list_create(&list, &opr, func);
|
||||
|
@ -1390,7 +1401,8 @@ static int rna_operator_invoke_cb(bContext *C, wmOperator *op, const wmEvent *ev
|
|||
void *ret;
|
||||
int result;
|
||||
|
||||
PointerRNA opr = RNA_pointer_create(nullptr, op->type->rna_ext.srna, op);
|
||||
ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
|
||||
PointerRNA opr = RNA_pointer_create(owner_id, op->type->rna_ext.srna, op);
|
||||
func = &rna_Operator_invoke_func; /* RNA_struct_find_function(&opr, "invoke"); */
|
||||
|
||||
RNA_parameter_list_create(&list, &opr, func);
|
||||
|
@ -1421,7 +1433,8 @@ static int rna_operator_modal_cb(bContext *C, wmOperator *op, const wmEvent *eve
|
|||
void *ret;
|
||||
int result;
|
||||
|
||||
PointerRNA opr = RNA_pointer_create(nullptr, op->type->rna_ext.srna, op);
|
||||
ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
|
||||
PointerRNA opr = RNA_pointer_create(owner_id, op->type->rna_ext.srna, op);
|
||||
func = &rna_Operator_modal_func; /* RNA_struct_find_function(&opr, "modal"); */
|
||||
|
||||
RNA_parameter_list_create(&list, &opr, func);
|
||||
|
@ -1444,7 +1457,10 @@ static void rna_operator_draw_cb(bContext *C, wmOperator *op)
|
|||
ParameterList list;
|
||||
FunctionRNA *func;
|
||||
|
||||
PointerRNA opr = RNA_pointer_create(nullptr, op->type->rna_ext.srna, op);
|
||||
/* Operator draw gets reused for drawing stored properties, in which
|
||||
* case we need a proper owner. */
|
||||
ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
|
||||
PointerRNA opr = RNA_pointer_create(owner_id, op->type->rna_ext.srna, op);
|
||||
func = &rna_Operator_draw_func; /* RNA_struct_find_function(&opr, "draw"); */
|
||||
|
||||
RNA_parameter_list_create(&list, &opr, func);
|
||||
|
@ -1462,7 +1478,8 @@ static void rna_operator_cancel_cb(bContext *C, wmOperator *op)
|
|||
ParameterList list;
|
||||
FunctionRNA *func;
|
||||
|
||||
PointerRNA opr = RNA_pointer_create(nullptr, op->type->rna_ext.srna, op);
|
||||
ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
|
||||
PointerRNA opr = RNA_pointer_create(owner_id, op->type->rna_ext.srna, op);
|
||||
func = &rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */
|
||||
|
||||
RNA_parameter_list_create(&list, &opr, func);
|
||||
|
@ -2034,6 +2051,7 @@ static void rna_def_operator(BlenderRNA *brna)
|
|||
|
||||
prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_struct_type(prop, "UILayout");
|
||||
RNA_def_property_pointer_funcs(prop, "rna_Operator_layout_get", nullptr, nullptr, nullptr);
|
||||
|
||||
prop = RNA_def_property(srna, "options", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
|
|
Loading…
Reference in New Issue