Skip to content

Threads dont work with optional arguments #38042

Closed
@2shady4u

Description

Godot version:
v3.2.1

OS/device including version:
Windows 10

Issue description:
Starting a new thread on a function with optional arguments doesn't work as expected.
Both calling the function normally and calling the function by emitting a signal works perfectly as expected.

Minimal reproduction project:

extends Node2D

var thread : Thread

signal test_signal

func _ready():
	thread = Thread.new()
	thread.start(self, "do_stuff")

	connect("test_signal", self, "do_stuff")
	emit_signal("test_signal")
	
	do_stuff()

func do_stuff(optional_var : int = 0):
	print("HURRAY!")

func _exit_tree():
	thread.wait_to_finish()

Gives following error when running:

E 0:00:00.812   _start_func: Could not call function 'do_stuff' to start thread 13480: Invalid Argument #0.
  <C++ Error>   Method failed.
  <C++ Source>  core/bind/core_bind.cpp:2694 @ _start_func()

Evidently running the start thread command with an actual integer as argument does work.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions