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>2017-10-16 08:35:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-16 08:38:02 +0300
commit83b60dac57a1aa432c8f7c165603ef327c6911d6 (patch)
tree0a02de6e19f92742d4a091dbfe64f275b52135f4 /source/blender
parent946a4fe85a1717001230ab5f256cf5cf10f045cb (diff)
WM: store modal operator last-properties
Avoids modal operators needing to explicitly store them.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c21
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c3
2 files changed, 9 insertions, 15 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index a6777d40398..6ebe1671afc 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -744,12 +744,16 @@ static bool wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot)
return wm && (wm->op_undo_depth == 0) && (ot->flag & (OPTYPE_REGISTER | OPTYPE_UNDO));
}
-static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat)
+static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat, const bool store)
{
wmWindowManager *wm = CTX_wm_manager(C);
op->customdata = NULL;
+ if (store) {
+ WM_operator_last_properties_store(op);
+ }
+
/* we don't want to do undo pushes for operators that are being
* called from operators that already do an undo push. usually
* this will happen for python operators that call C operators */
@@ -812,12 +816,7 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons
wm_operator_reports(C, op, retval, false);
if (retval & OPERATOR_FINISHED) {
- if (store) {
- if (wm->op_undo_depth == 0) { /* not called by py script */
- WM_operator_last_properties_store(op);
- }
- }
- wm_operator_finished(C, op, repeat);
+ wm_operator_finished(C, op, repeat, store && wm->op_undo_depth == 0);
}
else if (repeat == 0) {
/* warning: modal from exec is bad practice, but avoid crashing. */
@@ -1173,10 +1172,8 @@ static int wm_operator_invoke(
/* do nothing, wm_operator_exec() has been called somewhere */
}
else if (retval & OPERATOR_FINISHED) {
- if (!is_nested_call) { /* not called by py script */
- WM_operator_last_properties_store(op);
- }
- wm_operator_finished(C, op, 0);
+ const bool store = !is_nested_call;
+ wm_operator_finished(C, op, false, store);
}
else if (retval & OPERATOR_RUNNING_MODAL) {
/* take ownership of reports (in case python provided own) */
@@ -1752,7 +1749,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
/* important to run 'wm_operator_finished' before NULLing the context members */
if (retval & OPERATOR_FINISHED) {
- wm_operator_finished(C, op, 0);
+ wm_operator_finished(C, op, false, true);
handler->op = NULL;
}
else if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index e4776ea7b29..307c8b24c1e 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2491,9 +2491,6 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
case GESTURE_MODAL_CANCEL:
case GESTURE_MODAL_CONFIRM:
- /* Normally we wouldn't store last-properties on cancel,
- * this is an exception since the circle tool is modal. */
- WM_operator_last_properties_store(op);
wm_gesture_end(C, op);
return OPERATOR_FINISHED; /* use finish or we don't get an undo */
}