From 03f7d707e727658ad449e5b7c7f4bb444fbd4c2c Mon Sep 17 00:00:00 2001 From: Faymoon Date: Tue, 21 Apr 2020 15:18:50 +0200 Subject: [PATCH] Let thread func have optional parameter Fixes #38042. (cherry picked from commit 78ead60372c3342b15767265c0b0c976658ebc35) --- core/bind/core_bind.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 6198257091..71fc171eee 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2577,10 +2577,11 @@ void _Thread::_start_func(void *ud) { memdelete(tud); Variant::CallError ce; const Variant *arg[1] = { &t->userdata }; + int argc = (int)(arg[0]->get_type() != Variant::NIL); Thread::set_name(t->target_method); - t->ret = t->target_instance->call(t->target_method, arg, 1, ce); + t->ret = t->target_instance->call(t->target_method, arg, argc, ce); if (ce.error != Variant::CallError::CALL_OK) { String reason; switch (ce.error) {