From 3ad694018fe02447d9ad3051b9d2f6616bc52e74 Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Fri, 1 May 2020 18:41:41 +0200 Subject: Fix Container sorting not working when overriding _sort_children in gdscript Remove _sort_children from script bindings: _sort_children is an internal method which shouldn't be exposed to scripts. Added support for non-bound methods in MessageQueue: So we can use deferred calls without exposing internal methods to scripts. Added debug checks in CallableCustomMethodPointer: Adding method pointer callables to the message queue was causing crashes in case an object was destroyed and the same memory was allocated for another one. The new object had a valid object id but the call was erroneous. Release will be fixed later, along with Variant which has the same problem and is also fixed for debug only. --- core/message_queue.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'core/message_queue.cpp') diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 8c71f760b2..6dcf24e7ed 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -155,6 +155,21 @@ Error MessageQueue::push_callable(const Callable &p_callable, const Variant **p_ return OK; } +Error MessageQueue::push_callable(const Callable &p_callable, VARIANT_ARG_DECLARE) { + VARIANT_ARGPTRS; + + int argc = 0; + + for (int i = 0; i < VARIANT_ARG_MAX; i++) { + if (argptr[i]->get_type() == Variant::NIL) { + break; + } + argc++; + } + + return push_callable(p_callable, argptr, argc); +} + void MessageQueue::statistics() { Map set_count; Map notify_count; -- cgit v1.2.3