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

UndoRedo's do/undo methods can't go further than 5 arguments #26483

Closed
YeldhamDev opened this issue Mar 2, 2019 · 8 comments
Closed

UndoRedo's do/undo methods can't go further than 5 arguments #26483

YeldhamDev opened this issue Mar 2, 2019 · 8 comments

Comments

@YeldhamDev
Copy link
Member

Godot version:
b84b015

Issue description:
When using UndoRedo's do/undo methods, the number of arguments can't go further than 5, as anything else will be ignored.

Minimal reproduction project:
The following code will give an error stating that the test() method was only called with 5 arguments.

var _undo_redo := UndoRedo.new()

func _ready() -> void:
	_undo_redo.create_action("test")
	_undo_redo.add_do_method(self, "test",
			true, true, true, true, true, true, true)
	_undo_redo.commit_action()

func test(arg1: bool, arg2: bool, arg3: bool, arg4: bool, arg5: bool,
		arg6: bool, arg7: bool) -> void:
	print(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
@ghost
Copy link

ghost commented Mar 2, 2019

Limit is defined in core/object.h. Not sure why exactly 5.

#define VARIANT_ARG_MAX 5

@YeldhamDev
Copy link
Member Author

@Naryosha Then why methods like print() and call() can surpass it?

@ghost
Copy link

ghost commented Mar 2, 2019

Both functions don't refer to the VARIANT_ARG_MAX when looping through arguments. I think Object::call used to have the limit but it's overloaded by a newer method. Not sure. Git blame traces back to the beginning of time.

@YeldhamDev
Copy link
Member Author

@akien-mga Is there a reason for the argument limit to be 5, or is just arbitrary?

@Valeryn4
Copy link
Contributor

Valeryn4 commented Mar 4, 2019

function uses VARIANT_ARG_LIST
its makros "void add_do_method(Object *p_object, const String &p_method, VARIANT_ARG_LIST);"

But I do not know if the engine can work with "va_list".
I do not know the methods that can do any number of arguments.

"print" - works by its own rules, not through "D_METHOD".
There the function works directly with the output through "OS:print_liner(...)"

@Mantissa-23
Copy link

Just encountered this while developing a plugin. If it's not going to be fixed in the next update, then an error specific to exceeding VARIANT_ARG_MAX instead of just a generic Method expected X arguments, but called with 5. error would be valuable.

@KoBeWi
Copy link
Member

KoBeWi commented Aug 23, 2020

Still valid in 2ba96f0

@akien-mga
Copy link
Member

Fixed by #54188.

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

Successfully merging a pull request may close this issue.

6 participants