Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-12-19 18:04:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-12-19 18:07:09 +0400
commitaab587817c55f5c53672efe3b1fc4a0e953cb97e (patch)
treef7c7cd10964f7fdeb8256f47b3b56e81c5f8f528 /source/blender/editors/interface/interface.c
parent3fcfbf24b3c58eb0ed6e319027b347deea940a42 (diff)
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.
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c20
1 files changed, 14 insertions, 6 deletions
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)