diff options
author | Ignacio Etcheverry <neikeq@users.noreply.github.com> | 2018-07-04 21:30:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-04 21:30:49 +0200 |
commit | 02372bfdf7e81bb3e1a154f824665fc9ddbcd566 (patch) | |
tree | e024169399f0a08548531773a2305195abecb70d /modules | |
parent | 769f172602ebaac9afb8cf8e5761b7665f8666d5 (diff) | |
parent | 489c9adf03b369daf35132b40b7641592d9d0d15 (diff) |
Merge pull request #19872 from exts/export_signals
Mono: Fixes annotated signal loading in exported binaries
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mono/csharp_script.cpp | 57 | ||||
-rw-r--r-- | modules/mono/csharp_script.h | 3 |
2 files changed, 26 insertions, 34 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index caf502de9d..62a6b96bb5 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -745,10 +745,9 @@ void CSharpLanguage::reload_assemblies_if_needed(bool p_soft_reload) { for (Map<Ref<CSharpScript>, Map<ObjectID, List<Pair<StringName, Variant> > > >::Element *E = to_reload.front(); E; E = E->next()) { Ref<CSharpScript> scr = E->key(); - scr->signals_invalidated = true; scr->exports_invalidated = true; + scr->signals_invalidated = true; scr->reload(p_soft_reload); - scr->update_signals(); scr->update_exports(); //restore state if saved @@ -1579,37 +1578,33 @@ bool CSharpScript::_update_exports() { return false; } -bool CSharpScript::_update_signals() { - if (!valid) - return false; - - bool changed = false; - - if (signals_invalidated) { - signals_invalidated = false; +void CSharpScript::load_script_signals(GDMonoClass *p_class, GDMonoClass *p_native_class) { - GDMonoClass *top = script_class; + // no need to load the script's signals more than once + if (!signals_invalidated) { + return; + } - _signals.clear(); - changed = true; // TODO Do a real check for change + // make sure this classes signals are empty when loading for the first time + _signals.clear(); - while (top && top != native) { - const Vector<GDMonoClass *> &delegates = top->get_all_delegates(); - for (int i = delegates.size() - 1; i >= 0; --i) { - Vector<Argument> parameters; + GDMonoClass *top = p_class; + while (top && top != p_native_class) { + const Vector<GDMonoClass *> &delegates = top->get_all_delegates(); + for (int i = delegates.size() - 1; i >= 0; --i) { + Vector<Argument> parameters; - GDMonoClass *delegate = delegates[i]; + GDMonoClass *delegate = delegates[i]; - if (_get_signal(top, delegate, parameters)) { - _signals[delegate->get_name()] = parameters; - } + if (_get_signal(top, delegate, parameters)) { + _signals[delegate->get_name()] = parameters; } - - top = top->get_parent_class(); } + + top = top->get_parent_class(); } - return changed; + signals_invalidated = false; } bool CSharpScript::_get_signal(GDMonoClass *p_class, GDMonoClass *p_delegate, Vector<Argument> ¶ms) { @@ -1848,6 +1843,8 @@ Ref<CSharpScript> CSharpScript::create_for_managed_type(GDMonoClass *p_class) { top = top->get_parent_class(); } + script->load_script_signals(script->script_class, script->native); + return script; } @@ -1973,7 +1970,6 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) { PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(CSharpLanguage::get_singleton(), Ref<Script>(this), p_this)); placeholders.insert(si); _update_exports(); - _update_signals(); return si; #else return NULL; @@ -1992,8 +1988,6 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) { ERR_FAIL_V(NULL); } - update_signals(); - if (native) { String native_name = native->get_name(); if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) { @@ -2114,6 +2108,8 @@ Error CSharpScript::reload(bool p_keep_state) { top->fetch_methods_with_godot_api_checks(native); top = top->get_parent_class(); } + + load_script_signals(script_class, native); } return OK; @@ -2173,10 +2169,6 @@ void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const { } } -void CSharpScript::update_signals() { - _update_signals(); -} - Ref<Script> CSharpScript::get_base_script() const { // TODO search in metadata file once we have it, not important any way? @@ -2241,9 +2233,10 @@ CSharpScript::CSharpScript() : #ifdef TOOLS_ENABLED source_changed_cache = false; exports_invalidated = true; - signals_invalidated = true; #endif + signals_invalidated = true; + _resource_path_changed(); #ifdef DEBUG_ENABLED diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index cae2bbf40a..df597ba776 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -111,7 +111,7 @@ class CSharpScript : public Script { void _clear(); - bool _update_signals(); + void load_script_signals(GDMonoClass *p_class, GDMonoClass *p_native_class); bool _get_signal(GDMonoClass *p_class, GDMonoClass *p_delegate, Vector<Argument> ¶ms); bool _update_exports(); @@ -149,7 +149,6 @@ public: virtual bool has_script_signal(const StringName &p_signal) const; virtual void get_script_signal_list(List<MethodInfo> *r_signals) const; - virtual void update_signals(); /* TODO */ virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const; virtual void get_script_property_list(List<PropertyInfo> *p_list) const; |