Page MenuHome

Undo doesn't work properly in Node Editor
Closed, DuplicatePublicBUG

Description

System Information
Operating system: Windows 7
Graphics card: 'GeForce GTX 1050 Ti/PCIe/SSE2'

	               'NVIDIA Corporation'
                '4.5.0 NVIDIA 384.94'

Blender Version
version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: f6cb5f54494e, type:
build date: 2019-07-29, 09:41 AM

Short description of error
Making a cut and undoing works fine.

But any of steps below results in problems with undo:
Make a cut and move a node requires 3 undo's.
Make a cut and move a node and move a node again requires 5 undo's. One more move and it requires 7 undos.
If I make a cut and move a node 9 times it takes 19 times to undo.

Using a group node : Cutting a link and undoing in Edit Mode doesn't work at all.

Exact steps for others to reproduce the error

  • Default Cube : Click use Nodes.
  • Try any of the steps described above

Event Timeline

Germano Cavalcante (mano-wii) lowered the priority of this task from 90 to Low.

@Campbell Barton (campbellbarton), since this involves the undo system, I designed it for you.

Apparently the Links Cut tool increases the undo stack even when it does not cut any links.
Also, with the selection tool, click and drag correspond to two undos (select and move).

Cc @Brecht Van Lommel (brecht)

Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".

It seems wrong to assume that WM_gesture_lasso_modal always returns OPERATOR_FINISHED with the mouse click.
The operator's return is ignored and an undo step is always added.

It seems that the correct should be this:

diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index a5f32b4ff1f..d907b142f21 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -607,8 +607,9 @@ int WM_gesture_lines_invoke(bContext *C, wmOperator *op, const wmEvent *event)
   return OPERATOR_RUNNING_MODAL;
 }
 
-static void gesture_lasso_apply(bContext *C, wmOperator *op)
+static int gesture_lasso_apply(bContext *C, wmOperator *op)
 {
+  int retval = OPERATOR_FINISHED;
   wmGesture *gesture = op->customdata;
   PointerRNA itemptr;
   float loc[2];
@@ -628,9 +629,11 @@ static void gesture_lasso_apply(bContext *C, wmOperator *op)
   gesture_modal_end(C, op);
 
   if (op->type->exec) {
-    int retval = op->type->exec(C, op);
+    retval = op->type->exec(C, op);
     OPERATOR_RETVAL_CHECK(retval);
   }
+
+  return retval;
 }
 
 int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
@@ -672,8 +675,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
     case MIDDLEMOUSE:
     case RIGHTMOUSE:
       if (event->val == KM_RELEASE) { /* key release */
-        gesture_lasso_apply(C, op);
-        return OPERATOR_FINISHED;
+        return gesture_lasso_apply(C, op);
       }
       break;
     case ESCKEY:

Thanks for the report.
rB4b14f763da0e brought some change to the undo in that operator.
Problems with undo in Edit Mode has already been reported in T71895: Undo doesn't consider changes in nodetree when object is in edit mode
So I will close this report as a duplicate.