Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditorUndoRedoManager prints wrong errors if calling method fails #90863

Open
KoBeWi opened this issue Apr 18, 2024 · 1 comment
Open

EditorUndoRedoManager prints wrong errors if calling method fails #90863

KoBeWi opened this issue Apr 18, 2024 · 1 comment

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Apr 18, 2024

Tested versions

4.3 dev5 and earlier

System information

Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 31.0.15.4633) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)

Issue description

Consider this code:

@tool
extends EditorScript

func _run() -> void:
	var eur := EditorPlugin.new().get_undo_redo()
	eur.create_action("a")
	eur.add_do_method(get_scene(), "set_modulat", 1)
	eur.add_do_method(get_scene(), "draw_texture", 1)
	eur.add_undo_method(get_scene(), "set_modulat")
	eur.commit_action()

Assuming get_scene() returns Node2D, the first "do" method does not exist, while the second has wrong number of arguments. The errors printed are:

  C:\godot_source\core/object/undo_redo.cpp:367 - Error calling UndoRedo method operation 'set_modulat': 'Node2D::set_modulat': Instance is null
  C:\godot_source\core/object/undo_redo.cpp:367 - Error calling UndoRedo method operation 'draw_texture': 'Node2D::draw_texture': Method expected 3 arguments, but called with 0

The first error says "instance is null" (it's not)
The second error says the method is called with 0 arguments (while it uses 1)

Doesn't seem like a bug strictly in EditorUndoRedoManager (or UndoRedo), I don't know what's causing it.

Steps to reproduce

Run the code above.

Minimal reproduction project (MRP)

N/A

@jsjtxietian
Copy link
Contributor

is_valid doesn't distinguish whether the instance is null or it doesn't have the method

bool Callable::is_valid() const {
	if (is_custom()) {
		return get_custom()->is_valid();
	} else {
		return get_object() && get_object()->has_method(get_method());
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants