From f3c7527225c73812a7de10dfc273ba0e82e8d7ec Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Sun, 29 Jul 2018 22:40:09 +0200 Subject: Fix case where exported properties value is lost Fixes exported property modified values lost when creating a placeholder script instance with a failed script compilation - Object set/get will call PlaceHolderScriptInstance's new fallback set/get methods as a last resort. This way, placeholder script instances can keep the values for storage or until the script is compiled successfuly. - Script::can_instance() will only return true if a real script instance can be created. Otherwise, in the case of placeholder script instances, it will return false. - Object::set_script(script) is now in charge of requesting the creation of placeholder script instances. It's no longer Script::instance_create(owner)'s duty. - PlaceHolderScriptInstance has a new method set_build_failed(bool) to determine whether it should call into its script methods or not. - Fixed a few problems during reloading of C# scripts. --- core/script_language.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core/script_language.h') diff --git a/core/script_language.h b/core/script_language.h index 4e81b9b626..c24f237e36 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -115,6 +115,7 @@ public: virtual StringName get_instance_base_type() const = 0; // this may not work in all scripts, will return empty if so virtual ScriptInstance *instance_create(Object *p_this) = 0; + virtual PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) { return NULL; } virtual bool instance_has(const Object *p_this) const = 0; virtual bool has_source_code() const = 0; @@ -176,6 +177,9 @@ public: virtual bool is_placeholder() const { return false; } + virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid); + virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid); + virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const = 0; virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const = 0; @@ -319,6 +323,8 @@ class PlaceHolderScriptInstance : public ScriptInstance { ScriptLanguage *language; Ref