From ea85ff0dc2a04e695d396f62ce5949f4e04254e4 Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Thu, 10 Jan 2019 00:26:00 +0100 Subject: Fix properties being lost when reloading placeholder GDScript instance During reloading in `GDScriptLanguage::reload_all_scripts` a placeholder instance that must remain so is replaced with a new placeholder instance. The state is then restored by calling `ScriptInstance::set` for each property. This does not work if the script is missing the properties due to build/parse failing. The fix for such cases is to call `placeholder_set_fallback` instead of `set` on the script instance. I took this chance to move the `build_failed` flag from `PlaceHolderScriptInstance` to `Script`. That improves the code a lot. I also renamed it to `placeholder_fallback_enabled` which is a much better name (`build_failed` could lead to misunderstandings). --- core/script_language.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'core/script_language.h') diff --git a/core/script_language.h b/core/script_language.h index 654d1d4265..8543ed08b5 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -146,6 +146,8 @@ public: virtual void get_constants(Map *p_constants) {} virtual void get_members(Set *p_constants) {} + virtual bool is_placeholder_fallback_enabled() const { return false; } + Script() {} }; @@ -334,8 +336,6 @@ class PlaceHolderScriptInstance : public ScriptInstance { ScriptLanguage *language; Ref