From aab587817c55f5c53672efe3b1fc4a0e953cb97e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 20 Dec 2013 01:04:01 +1100 Subject: Fix T37795: Resetting a button to the default value could crash Added ui_handle_afterfunc_add_operator so a button can queue an operator to run without executing it immediately. --- source/blender/editors/interface/interface.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/interface/interface.c') diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index d09b3dea98a..b1c66a65c35 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2055,15 +2055,23 @@ bool ui_set_but_string(bContext *C, uiBut *but, const char *str) return false; } -void ui_set_but_default(bContext *C, const bool all) +void ui_set_but_default(bContext *C, const bool all, const bool use_afterfunc) { const char *opstring = "UI_OT_reset_default_button"; - PointerRNA ptr; - WM_operator_properties_create(&ptr, opstring); - RNA_boolean_set(&ptr, "all", all); - WM_operator_name_call(C, opstring, WM_OP_EXEC_DEFAULT, &ptr); - WM_operator_properties_free(&ptr); + if (use_afterfunc) { + PointerRNA *ptr; + wmOperatorType *ot = WM_operatortype_find(opstring, 0); + ptr = ui_handle_afterfunc_add_operator(ot, WM_OP_EXEC_DEFAULT, true); + RNA_boolean_set(ptr, "all", all); + } + else { + PointerRNA ptr; + WM_operator_properties_create(&ptr, opstring); + RNA_boolean_set(&ptr, "all", all); + WM_operator_name_call(C, opstring, WM_OP_EXEC_DEFAULT, &ptr); + WM_operator_properties_free(&ptr); + } } static double soft_range_round_up(double value, double max) -- cgit v1.2.3