Open
Description
Godot version:
99da466
OS/device including version:
Ubuntu 17.10
Issue description:
After this, I'm done torturing UndoRedo, I think. :)
There doesn't appear to be any way out of a create_action() once you've started it. There's a commit but no rollback. If one expects another create_action() to discard the previous commands, they're treated to an error and a now-broken commit.
Steps to reproduce:
todd@todd-ab28d3:~/repos/remote/brainsick-godot-tests$ cat tests/qa/classes/UndoRedoTest-uncommit.gd
extends MainLoop
var testobject1
var undoredo
func _initialize():
testobject1 = TestClass.new()
testobject1.set_prop(1)
undoredo = UndoRedo.new()
# main test body
func _iteration(delta):
test_create_uncommit()
test_create_commit()
return true # exit MainLoop
func _finalize():
undoredo.free()
func test_create_uncommit():
undoredo.create_action('first action - method')
undoredo.add_do_method(testobject1, 'set_prop', 2)
undoredo.add_undo_method(testobject1, 'set_prop', testobject1.get_prop())
#undoredo.commit_action()
# where's rollback?
assert(testobject1.prop == 1)
func test_create_commit():
undoredo.create_action('second action - property')
#undoredo.create_action('second action - property', UndoRedo.MERGE_DISABLE)
#undoredo.create_action('second action - property', UndoRedo.MERGE_ENDS)
#undoredo.create_action('second action - property', UndoRedo.MERGE_ALL)
undoredo.add_do_property(testobject1, 'prop', 3)
undoredo.add_undo_property(testobject1, 'prop', testobject1.prop)
undoredo.commit_action()
assert(testobject1.prop == 3)
class TestClass:
var prop
func get_prop():
return prop
func set_prop(prop):
self.prop = prop
todd@todd-ab28d3:~/repos/remote/brainsick-godot-tests$ ../brainsick-godot/bin/godot.x11.tools.64 -s tests/qa/classes/UndoRedoTest-uncommit.gd
No touch devices found
OpenGL ES 3.0 Renderer: AMD Radeon (TM) R9 Fury Series (AMD FIJI / DRM 3.18.0 / 4.13.0-21-generic, LLVM 5.0.0)
GLES3: max ubo light: 409
GLES3: max ubo reflections: 455, ubo size: 144
ARVR: Registered interface: Native mobile
SCRIPT ERROR: test_create_commit: Assertion failed.
At: res://tests/qa/classes/UndoRedoTest-uncommit.gd:40.
ERROR: clear_history: Condition ' action_level > 0 ' is true.
At: core/undo_redo.cpp:326.
I have an updated, more robust test at godotengine/godot-tests#3.