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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-11-28 20:42:39 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-11-28 20:42:39 +0400
commit0aad9f674a1fcdd983946e8b3e011157492495a8 (patch)
treeeaced2f91ca970d1ef71dbf63051a0646038bca8
parent4c1363358255d4d11d8974df1ecf1cc8b32b8736 (diff)
Move to Layer: optimization so that the first change in the popup menu does
not do an undo push & undo step, there's no reason this is needed. In principle this particular operator doesn't ever need an undo on changes, even for further steps, but that's harder to solve.
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 9968d81e7b4..80ceb5700e5 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1025,6 +1025,23 @@ wmOperator *WM_operator_last_redo(const bContext *C)
return op;
}
+static void wm_block_redo_cb(bContext *C, void *arg_op, int UNUSED(arg_event))
+{
+ wmOperator *op = arg_op;
+
+ if (op == WM_operator_last_redo(C)) {
+ /* operator was already executed once? undo & repeat */
+ ED_undo_operator_repeat(C, op);
+ }
+ else {
+ /* operator not executed yet, call it */
+ ED_undo_push_op(C, op);
+ wm_operator_register(C, op);
+
+ WM_operator_repeat(C, op);
+ }
+}
+
static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
{
wmOperator *op = arg_op;
@@ -1032,7 +1049,6 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
uiLayout *layout;
uiStyle *style = UI_GetStyle();
int width = 300;
-
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockClearFlag(block, UI_BLOCK_LOOP);
@@ -1042,11 +1058,12 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
* ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */
assert(op->type->flag & OPTYPE_REGISTER);
- uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, arg_op);
+ uiBlockSetHandleFunc(block, wm_block_redo_cb, arg_op);
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, UI_UNIT_Y, style);
- if (!WM_operator_check_ui_enabled(C, op->type->name))
- uiLayoutSetEnabled(layout, FALSE);
+ if (op == WM_operator_last_redo(C))
+ if (!WM_operator_check_ui_enabled(C, op->type->name))
+ uiLayoutSetEnabled(layout, FALSE);
if (op->type->flag & OPTYPE_MACRO) {
for (op = op->macro.first; op; op = op->next) {
@@ -1058,7 +1075,6 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE);
}
-
uiPopupBoundsBlock(block, 4, 0, 0);
uiEndBlock(C, block);
@@ -1218,15 +1234,10 @@ static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, const int do_
if (!(U.uiflag & USER_GLOBALUNDO))
return WM_operator_props_dialog_popup(C, op, 300, UI_UNIT_Y);
- ED_undo_push_op(C, op);
-
- wm_operator_register(C, op);
-
uiPupBlock(C, wm_block_create_redo, op);
- if (do_call) {
- WM_operator_repeat(C, op);
- }
+ if (do_call)
+ wm_block_redo_cb(C, op, 0);
return OPERATOR_RUNNING_MODAL;
}