From b3cac9c0923f0afb520a35c0e792a6a73868fa84 Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Sat, 10 Feb 2024 13:19:14 -0600 Subject: [PATCH] Allow Ref `instantiate` to accept constructor args --- core/debugger/remote_debugger.cpp | 2 +- core/object/ref_counted.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index fe9e468774e..6f2036705db 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -665,7 +665,7 @@ RemoteDebugger::RemoteDebugger(Ref p_peer) { // Performance Profiler Object *perf = Engine::get_singleton()->get_singleton_object("Performance"); if (perf) { - performance_profiler = Ref(memnew(PerformanceProfiler(perf))); + performance_profiler.instantiate(perf); performance_profiler->bind("performance"); profiler_enable("performance", true); } diff --git a/core/object/ref_counted.h b/core/object/ref_counted.h index 228373d6625..10be27b8795 100644 --- a/core/object/ref_counted.h +++ b/core/object/ref_counted.h @@ -212,8 +212,9 @@ public: reference = nullptr; } - void instantiate() { - ref(memnew(T)); + template + void instantiate(VarArgs... p_params) { + ref(memnew(T(p_params...))); } Ref() {}