From 619d9d143baff60827249a5592b2117675ae88f1 Mon Sep 17 00:00:00 2001 From: "C.Even" Date: Tue, 29 Mar 2022 11:48:49 +0800 Subject: Fix Callable::bind usage in connections_dialog.h and packed_scene.cpp * Callable::bind takes an array of pointers to Variant * Fixes #57057 --- editor/connections_dialog.h | 7 +++++-- scene/resources/packed_scene.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index a075ff0c55..58c584b8b2 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -93,8 +93,11 @@ public: if (unbinds > 0) { return Callable(target, method).unbind(unbinds); } else if (!binds.is_empty()) { - const Variant *args = binds.ptr(); - return Callable(target, method).bind(&args, binds.size()); + const Variant **argptrs = (const Variant **)alloca(sizeof(Variant *) * binds.size()); + for (int i = 0; i < binds.size(); i++) { + argptrs[i] = &binds[i]; + } + return Callable(target, method).bind(argptrs, binds.size()); } else { return Callable(target, method); } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index a3e356feaf..b1c2702a1e 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -362,8 +362,11 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const { } } - const Variant *args = binds.ptr(); - callable = callable.bind(&args, binds.size()); + const Variant **argptrs = (const Variant **)alloca(sizeof(Variant *) * binds.size()); + for (int j = 0; j < binds.size(); j++) { + argptrs[j] = &binds[j]; + } + callable = callable.bind(argptrs, binds.size()); } cfrom->connect(snames[c.signal], callable, varray(), CONNECT_PERSIST | c.flags); -- cgit v1.2.3