You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-13 13:31:48 +00:00
CSharpScript should not own base script signals
This commit is contained in:
@@ -1764,8 +1764,9 @@ void CSharpInstance::mono_object_disposed_baseref(GCHandleIntPtr p_gchandle_to_f
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CSharpInstance::connect_event_signals() {
|
void CSharpInstance::connect_event_signals() {
|
||||||
// The script signals list includes the signals declared in base scripts.
|
const CSharpScript *top = script.ptr();
|
||||||
for (CSharpScript::EventSignalInfo &signal : script->get_script_event_signals()) {
|
while (top != nullptr && top->valid) {
|
||||||
|
for (const CSharpScript::EventSignalInfo &signal : top->event_signals) {
|
||||||
String signal_name = signal.name;
|
String signal_name = signal.name;
|
||||||
|
|
||||||
// TODO: Use pooling for ManagedCallable instances.
|
// TODO: Use pooling for ManagedCallable instances.
|
||||||
@@ -1775,6 +1776,8 @@ void CSharpInstance::connect_event_signals() {
|
|||||||
connected_event_signals.push_back(callable);
|
connected_event_signals.push_back(callable);
|
||||||
owner->connect(signal_name, callable);
|
owner->connect(signal_name, callable);
|
||||||
}
|
}
|
||||||
|
top = top->base_script.ptr();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSharpInstance::disconnect_event_signals() {
|
void CSharpInstance::disconnect_event_signals() {
|
||||||
@@ -2617,25 +2620,33 @@ bool CSharpScript::has_script_signal(const StringName &p_signal) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (base_script.is_valid()) {
|
||||||
|
return base_script->has_script_signal(p_signal);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
|
void CSharpScript::_get_script_signal_list(List<MethodInfo> *r_signals, bool p_include_base) const {
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const EventSignalInfo &signal : get_script_event_signals()) {
|
for (const EventSignalInfo &signal : event_signals) {
|
||||||
r_signals->push_back(signal.method_info);
|
r_signals->push_back(signal.method_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!p_include_base) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<CSharpScript::EventSignalInfo> CSharpScript::get_script_event_signals() const {
|
if (base_script.is_valid()) {
|
||||||
if (!valid) {
|
base_script->get_script_signal_list(r_signals);
|
||||||
return Vector<EventSignalInfo>();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return event_signals;
|
void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
|
||||||
|
_get_script_signal_list(r_signals, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSharpScript::inherits_script(const Ref<Script> &p_script) const {
|
bool CSharpScript::inherits_script(const Ref<Script> &p_script) const {
|
||||||
|
|||||||
@@ -215,6 +215,8 @@ private:
|
|||||||
// Do not use unless you know what you are doing
|
// Do not use unless you know what you are doing
|
||||||
static void update_script_class_info(Ref<CSharpScript> p_script);
|
static void update_script_class_info(Ref<CSharpScript> p_script);
|
||||||
|
|
||||||
|
void _get_script_signal_list(List<MethodInfo> *r_signals, bool p_include_base) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
@@ -251,8 +253,6 @@ public:
|
|||||||
bool has_script_signal(const StringName &p_signal) const override;
|
bool has_script_signal(const StringName &p_signal) const override;
|
||||||
void get_script_signal_list(List<MethodInfo> *r_signals) const override;
|
void get_script_signal_list(List<MethodInfo> *r_signals) const override;
|
||||||
|
|
||||||
Vector<EventSignalInfo> get_script_event_signals() const;
|
|
||||||
|
|
||||||
bool get_property_default_value(const StringName &p_property, Variant &r_value) const override;
|
bool get_property_default_value(const StringName &p_property, Variant &r_value) const override;
|
||||||
void get_script_property_list(List<PropertyInfo> *r_list) const override;
|
void get_script_property_list(List<PropertyInfo> *r_list) const override;
|
||||||
void update_exports() override;
|
void update_exports() override;
|
||||||
|
|||||||
@@ -798,15 +798,15 @@ namespace Godot.Bridge
|
|||||||
|
|
||||||
GetScriptTypeInfo(scriptType, outTypeInfo);
|
GetScriptTypeInfo(scriptType, outTypeInfo);
|
||||||
|
|
||||||
|
Type native = GodotObject.InternalGetClassNativeBase(scriptType);
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
|
|
||||||
// Performance is not critical here as this will be replaced with source generators.
|
// Performance is not critical here as this will be replaced with source generators.
|
||||||
using var methods = new Collections.Array();
|
using var methods = new Collections.Array();
|
||||||
|
|
||||||
Type? top = scriptType;
|
Type? top = scriptType;
|
||||||
Type native = GodotObject.InternalGetClassNativeBase(scriptType);
|
if (scriptType != native)
|
||||||
|
|
||||||
if (scriptType != null && scriptType != native)
|
|
||||||
{
|
{
|
||||||
var methodList = GetMethodListForType(scriptType);
|
var methodList = GetMethodListForType(scriptType);
|
||||||
|
|
||||||
@@ -910,11 +910,9 @@ namespace Godot.Bridge
|
|||||||
// Performance is not critical here as this will be replaced with source generators.
|
// Performance is not critical here as this will be replaced with source generators.
|
||||||
using var signals = new Collections.Dictionary();
|
using var signals = new Collections.Dictionary();
|
||||||
|
|
||||||
top = scriptType;
|
if (scriptType != native)
|
||||||
|
|
||||||
while (top != null && top != native)
|
|
||||||
{
|
{
|
||||||
var signalList = GetSignalListForType(top);
|
var signalList = GetSignalListForType(scriptType);
|
||||||
|
|
||||||
if (signalList != null)
|
if (signalList != null)
|
||||||
{
|
{
|
||||||
@@ -949,8 +947,6 @@ namespace Godot.Bridge
|
|||||||
signals.Add(signalName, signalParams);
|
signals.Add(signalName, signalParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
top = top.BaseType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*outEventSignalsDest = NativeFuncs.godotsharp_dictionary_new_copy(
|
*outEventSignalsDest = NativeFuncs.godotsharp_dictionary_new_copy(
|
||||||
|
|||||||
Reference in New Issue
Block a user