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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-02-22 08:43:23 +0300
committerCampbell Barton <campbell@blender.org>2022-02-22 08:43:23 +0300
commit2cd33955beb3661b81ae14408d366e1152cd0c63 (patch)
tree69bada1a3b92d30beaef97aa3a0416a55cbfa134 /source
parent2234bfbcdb14299aa2ed28ed3ee6682c6d9a7a0c (diff)
parentc5b66560de75a54b5c6920fb675c0d804caeb724 (diff)
Merge branch 'blender-v3.1-release'
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface_handlers.c7
-rw-r--r--source/blender/editors/interface/interface_ops.c21
3 files changed, 25 insertions, 5 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 7bbc8249a97..060c9dc33d6 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2902,7 +2902,7 @@ uiBut *UI_context_active_but_prop_get(const struct bContext *C,
struct PointerRNA *r_ptr,
struct PropertyRNA **r_prop,
int *r_index);
-void UI_context_active_but_prop_handle(struct bContext *C);
+void UI_context_active_but_prop_handle(struct bContext *C, bool handle_undo);
void UI_context_active_but_clear(struct bContext *C, struct wmWindow *win, struct ARegion *region);
struct wmOperator *UI_context_active_operator_get(const struct bContext *C);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index bbb6bfabdd1..9dcee73f6bb 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -8793,7 +8793,7 @@ uiBut *UI_context_active_but_prop_get(const bContext *C,
return activebut;
}
-void UI_context_active_but_prop_handle(bContext *C)
+void UI_context_active_but_prop_handle(bContext *C, const bool handle_undo)
{
uiBut *activebut = ui_context_rna_button_active(C);
if (activebut) {
@@ -8804,6 +8804,11 @@ void UI_context_active_but_prop_handle(bContext *C)
if (block->handle_func) {
block->handle_func(C, block->handle_func_arg, activebut->retval);
}
+ if (handle_undo) {
+ /* Update the button so the undo text uses the correct value. */
+ ui_but_update(activebut);
+ ui_apply_but_undo(activebut);
+ }
}
}
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index a96f14d7435..498c22748ce 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -314,7 +314,7 @@ static int operator_button_property_finish(bContext *C, PointerRNA *ptr, Propert
RNA_property_update(C, ptr, prop);
/* as if we pressed the button */
- UI_context_active_but_prop_handle(C);
+ UI_context_active_but_prop_handle(C, false);
/* Since we don't want to undo _all_ edits to settings, eg window
* edits on the screen or on operator settings.
@@ -326,6 +326,19 @@ static int operator_button_property_finish(bContext *C, PointerRNA *ptr, Propert
return OPERATOR_CANCELLED;
}
+static int operator_button_property_finish_with_undo(bContext *C,
+ PointerRNA *ptr,
+ PropertyRNA *prop)
+{
+ /* Perform updates required for this property. */
+ RNA_property_update(C, ptr, prop);
+
+ /* As if we pressed the button. */
+ UI_context_active_but_prop_handle(C, true);
+
+ return OPERATOR_FINISHED;
+}
+
static bool reset_default_button_poll(bContext *C)
{
PointerRNA ptr;
@@ -350,7 +363,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
/* if there is a valid property that is editable... */
if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
if (RNA_property_reset(&ptr, prop, (all) ? -1 : index)) {
- return operator_button_property_finish(C, &ptr, prop);
+ return operator_button_property_finish_with_undo(C, &ptr, prop);
}
}
@@ -369,7 +382,9 @@ static void UI_OT_reset_default_button(wmOperatorType *ot)
ot->exec = reset_default_button_exec;
/* flags */
- ot->flag = OPTYPE_UNDO;
+ /* Don't set #OPTYPE_UNDO because #operator_button_property_finish_with_undo
+ * is responsible for the undo push. */
+ ot->flag = 0;
/* properties */
RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");