Godot Engine – Multi-platform 2D and 3D game engine
Remove `p_soft_reload` from `ScriptLanguage` reload callbacks
HolonProduction7db056a9ecc5
diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cppindex 4764bbcef84..48a88c1dcec 100644--- a/core/debugger/remote_debugger.cpp+++ b/core/debugger/remote_debugger.cpp@@ -712,7 +712,7 @@ void RemoteDebugger::poll_events(bool p_is_idle) {scripts_to_reload.push_back(script);}for (int i = 0; i < ScriptServer::get_language_count(); i++) {- ScriptServer::get_language(i)->reload_scripts(scripts_to_reload, true);+ ScriptServer::get_language(i)->reload_scripts(scripts_to_reload);}}script_paths_to_reload.clear();diff --git a/core/object/script_language.cpp b/core/object/script_language.cppindex a2322a4fc16..222be56801a 100644--- a/core/object/script_language.cpp+++ b/core/object/script_language.cpp@@ -200,10 +200,10 @@ void Script::_bind_methods() {void Script::reload_from_file() {#ifdef TOOLS_ENABLEDif (Engine::get_singleton()->is_editor_hint() && is_tool()) {- get_language()->reload_tool_script(this, true);+ get_language()->reload_tool_script(this);} else {Array scripts = { this };- get_language()->reload_scripts(scripts, true);+ get_language()->reload_scripts(scripts);}#elseResource::reload_from_file();diff --git a/core/object/script_language.h b/core/object/script_language.hindex 0e9cb53e2b4..b0d87105bf4 100644--- a/core/object/script_language.h+++ b/core/object/script_language.h@@ -400,8 +400,8 @@ public:virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); }virtual void reload_all_scripts() = 0;- virtual void reload_scripts(const Array &p_scripts, bool p_soft_reload) = 0;- virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) = 0;+ virtual void reload_scripts(const Array &p_scripts) = 0;+ virtual void reload_tool_script(const Ref<Script> &p_script) = 0;/* LOADER FUNCTIONS */virtual void get_recognized_extensions(List<String> *p_extensions) const = 0;diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.hindex 9cdde40beca..d8a207f648c 100644--- a/core/object/script_language_extension.h+++ b/core/object/script_language_extension.h@@ -656,8 +656,14 @@ public:}EXBIND0(reload_all_scripts)- EXBIND2(reload_scripts, const Array &, bool)- EXBIND2(reload_tool_script, const Ref<Script> &, bool)+ GDVIRTUAL2_REQUIRED(_reload_scripts, const Array &, bool);+ virtual void reload_scripts(const Array &p_scripts) override {+ GDVIRTUAL_CALL(_reload_scripts, p_scripts, true);+ }+ GDVIRTUAL2_REQUIRED(_reload_tool_script, const Ref<Script> &, bool);+ virtual void reload_tool_script(const Ref<Script> &p_script) override {+ GDVIRTUAL_CALL(_reload_tool_script, p_script, true);+ }/* LOADER FUNCTIONS */GDVIRTUAL0RC_REQUIRED(PackedStringArray, _get_recognized_extensions)diff --git a/doc/classes/ScriptLanguageExtension.xml b/doc/classes/ScriptLanguageExtension.xmlindex cf41bcee044..c724783ec11 100644--- a/doc/classes/ScriptLanguageExtension.xml+++ b/doc/classes/ScriptLanguageExtension.xml@@ -320,6 +320,7 @@<param index="1" name="soft_reload" type="bool" /><description>Reloads all [param scripts] from disk and the specifics of how that happens is [ScriptLanguageExtension] specific.+ [param soft_reload] is always [code]true[/code].</description></method><method name="_reload_tool_script" qualifiers="virtual required">@@ -328,6 +329,7 @@<param index="1" name="soft_reload" type="bool" /><description>Reloads the given [param script] from disk and the specifics of how that happens is [ScriptLanguageExtension] specific.+ [param soft_reload] is always [code]true[/code].</description></method><method name="_remove_named_global_constant" qualifiers="virtual required">diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cppindex 9fc63261f30..7c66c334290 100644--- a/modules/gdscript/gdscript.cpp+++ b/modules/gdscript/gdscript.cpp@@ -2502,11 +2502,11 @@ void GDScriptLanguage::reload_all_scripts() {#endif // TOOLS_ENABLED}- reload_scripts(scripts, true);+ reload_scripts(scripts);#endif // DEBUG_ENABLED}-void GDScriptLanguage::reload_scripts(const Array &p_scripts, bool p_soft_reload) {+void GDScriptLanguage::reload_scripts(const Array &p_scripts) {#ifdef DEBUG_ENABLEDList<Ref<GDScript>> scripts;@@ -2539,44 +2539,6 @@ void GDScriptLanguage::reload_scripts(const Array &p_scripts, bool p_soft_reload}to_reload.insert(scr, HashMap<ObjectID, List<Pair<StringName, Variant>>>());-- if (!p_soft_reload) {- //save state and remove script from instances- HashMap<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[scr];-- while (scr->instances.first()) {- GDScriptInstance *instance = scr->instances.first()->self();- //save instance info- List<Pair<StringName, Variant>> state;- instance->get_property_state(state);- map[instance->get_owner()->get_instance_id()] = state;- instance->get_owner()->set_script(Variant());- }-- //same thing for placeholders-#ifdef TOOLS_ENABLED-- while (scr->placeholders.size()) {- Object *obj = (*scr->placeholders.begin())->get_owner();-- //save instance info- if (obj->get_script_instance()) {- map.insert(obj->get_instance_id(), List<Pair<StringName, Variant>>());- List<Pair<StringName, Variant>> &state = map[obj->get_instance_id()];- obj->get_script_instance()->get_property_state(state);- obj->set_script(Variant());- } else {- // no instance found. Let's remove it so we don't loop forever- scr->placeholders.erase(*scr->placeholders.begin());- }- }--#endif // TOOLS_ENABLED-- for (const KeyValue<ObjectID, List<Pair<StringName, Variant>>> &F : scr->pending_reload_state) {- map[F.key] = F.value; //pending to reload, use this one instead- }- }}for (KeyValue<Ref<GDScript>, HashMap<ObjectID, List<Pair<StringName, Variant>>>> &E : to_reload) {@@ -2595,7 +2557,7 @@ void GDScriptLanguage::reload_scripts(const Array &p_scripts, bool p_soft_reload} else {scr->load_source_code(scr->get_path());}- scr->reload(p_soft_reload);+ scr->reload(true);//restore state if savedfor (KeyValue<ObjectID, List<Pair<StringName, Variant>>> &F : E.value) {@@ -2606,10 +2568,6 @@ void GDScriptLanguage::reload_scripts(const Array &p_scripts, bool p_soft_reloadcontinue;}- if (!p_soft_reload) {- //clear it just in case (may be a pending reload state)- obj->set_script(Variant());- }obj->set_script(scr);ScriptInstance *script_inst = obj->get_script_instance();@@ -2642,9 +2600,9 @@ void GDScriptLanguage::reload_scripts(const Array &p_scripts, bool p_soft_reload#endif // DEBUG_ENABLED}-void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {+void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script) {Array scripts = { p_script };- reload_scripts(scripts, p_soft_reload);+ reload_scripts(scripts);}void GDScriptLanguage::frame() {diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.hindex dfb37b5bd48..5a68fb1167d 100644--- a/modules/gdscript/gdscript.h+++ b/modules/gdscript/gdscript.h@@ -621,8 +621,8 @@ public:virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1) override;virtual void reload_all_scripts() override;- virtual void reload_scripts(const Array &p_scripts, bool p_soft_reload) override;- virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) override;+ virtual void reload_scripts(const Array &p_scripts) override;+ virtual void reload_tool_script(const Ref<Script> &p_script) override;virtual void frame() override;diff --git a/modules/gdscript/gdscript_resource_format.cpp b/modules/gdscript/gdscript_resource_format.cppindex e60892f83d5..70d350660c8 100644--- a/modules/gdscript/gdscript_resource_format.cpp+++ b/modules/gdscript/gdscript_resource_format.cpp@@ -171,7 +171,7 @@ Error ResourceFormatSaverGDScript::save(const Ref<Resource> &p_resource, const S}if (ScriptServer::is_reload_scripts_on_save_enabled()) {- GDScriptLanguage::get_singleton()->reload_tool_script(p_resource, true);+ GDScriptLanguage::get_singleton()->reload_tool_script(p_resource);}return OK;diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cppindex 5fb1a5fd43c..7db259f9f8b 100644--- a/modules/gdscript/language_server/gdscript_text_document.cpp+++ b/modules/gdscript/language_server/gdscript_text_document.cpp@@ -98,7 +98,7 @@ void GDScriptTextDocument::didSave(const Variant &p_param) {Ref<GDScript> scr = ResourceLoader::load(path);if (scr.is_valid() && (scr->load_source_code(path) == OK)) {if (scr->is_tool()) {- scr->get_language()->reload_tool_script(scr, true);+ scr->get_language()->reload_tool_script(scr);} else {scr->reload(true);}diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cppindex bdb76e25458..ea7befe7515 100644--- a/modules/mono/csharp_script.cpp+++ b/modules/mono/csharp_script.cpp@@ -563,20 +563,20 @@ struct CSharpScriptDepSort {void CSharpLanguage::reload_all_scripts() {#ifdef GD_MONO_HOT_RELOADif (is_assembly_reloading_needed()) {- reload_assemblies(false);+ reload_assemblies();}#endif}-void CSharpLanguage::reload_scripts(const Array &p_scripts, bool p_soft_reload) {+void CSharpLanguage::reload_scripts(const Array &p_scripts) {#ifdef GD_MONO_HOT_RELOADif (is_assembly_reloading_needed()) {- reload_assemblies(p_soft_reload);+ reload_assemblies();}#endif}-void CSharpLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {+void CSharpLanguage::reload_tool_script(const Ref<Script> &p_script) {CRASH_COND(!Engine::get_singleton()->is_editor_hint());#ifdef TOOLS_ENABLED@@ -585,7 +585,7 @@ void CSharpLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft#ifdef GD_MONO_HOT_RELOADif (is_assembly_reloading_needed()) {- reload_assemblies(p_soft_reload);+ reload_assemblies();}#endif}@@ -622,7 +622,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() {return true;}-void CSharpLanguage::reload_assemblies(bool p_soft_reload) {+void CSharpLanguage::reload_assemblies() {ERR_FAIL_NULL(gdmono);if (!gdmono->is_runtime_initialized()) {return;@@ -865,7 +865,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {#endifif (!scr->get_path().is_empty() && !scr->get_path().begins_with("csharp://")) {- scr->reload(p_soft_reload);+ scr->reload();if (!scr->valid) {scr->pending_reload_instances.clear();diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.hindex c16b133a630..a906977aa0b 100644--- a/modules/mono/csharp_script.h+++ b/modules/mono/csharp_script.h@@ -481,7 +481,7 @@ public:#ifdef GD_MONO_HOT_RELOADbool is_assembly_reloading_needed();- void reload_assemblies(bool p_soft_reload);+ void reload_assemblies();#endif_FORCE_INLINE_ ManagedCallableMiddleman *get_managed_callable_middleman() const {@@ -560,8 +560,8 @@ public:/* TODO? */ void get_public_annotations(List<MethodInfo> *p_annotations) const override {}void reload_all_scripts() override;- void reload_scripts(const Array &p_scripts, bool p_soft_reload) override;- void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) override;+ void reload_scripts(const Array &p_scripts) override;+ void reload_tool_script(const Ref<Script> &p_script) override;/* LOADER FUNCTIONS */void get_recognized_extensions(List<String> *p_extensions) const override;diff --git a/modules/mono/csharp_script_resource_format.cpp b/modules/mono/csharp_script_resource_format.cppindex 61f6772b70a..0f57969ed39 100644--- a/modules/mono/csharp_script_resource_format.cpp+++ b/modules/mono/csharp_script_resource_format.cpp@@ -142,7 +142,7 @@ Error ResourceFormatSaverCSharpScript::save(const Ref<Resource> &p_resource, con#ifdef TOOLS_ENABLEDif (ScriptServer::is_reload_scripts_on_save_enabled()) {- CSharpLanguage::get_singleton()->reload_tool_script(p_resource, false);+ CSharpLanguage::get_singleton()->reload_tool_script(p_resource);}#endifdiff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.csindex eadac828e8c..a95bc289bfa 100644--- a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs+++ b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs@@ -88,7 +88,7 @@ namespace GodotTools.Buildif (Internal.IsAssembliesReloadingNeeded()){BuildManager.UpdateLastValidBuildDateTime();- Internal.ReloadAssemblies(softReload: false);+ Internal.ReloadAssemblies();}}@@ -109,7 +109,7 @@ namespace GodotTools.Buildif (Internal.IsAssembliesReloadingNeeded()){BuildManager.UpdateLastValidBuildDateTime();- Internal.ReloadAssemblies(softReload: false);+ Internal.ReloadAssemblies();}}diff --git a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.csindex 638b7d64204..75ba1c928e9 100644--- a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs+++ b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs@@ -20,7 +20,7 @@ namespace GodotToolsif (Internal.IsAssembliesReloadingNeeded()){BuildManager.UpdateLastValidBuildDateTime();- Internal.ReloadAssemblies(softReload: false);+ Internal.ReloadAssemblies();}}}@@ -30,7 +30,7 @@ namespace GodotToolsif (Internal.IsAssembliesReloadingNeeded()){BuildManager.UpdateLastValidBuildDateTime();- Internal.ReloadAssemblies(softReload: false);+ Internal.ReloadAssemblies();}}diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.csindex 225ac4073b3..4c306158888 100644--- a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs@@ -50,7 +50,7 @@ namespace GodotTools.Internalspublic static bool IsAssembliesReloadingNeeded() => godot_icall_Internal_IsAssembliesReloadingNeeded();- public static void ReloadAssemblies(bool softReload) => godot_icall_Internal_ReloadAssemblies(softReload);+ public static void ReloadAssemblies() => godot_icall_Internal_ReloadAssemblies();public static void EditorDebuggerNodeReloadScripts() => godot_icall_Internal_EditorDebuggerNodeReloadScripts();@@ -138,7 +138,7 @@ namespace GodotTools.Internalsprivate static partial bool godot_icall_Internal_IsAssembliesReloadingNeeded();- private static partial void godot_icall_Internal_ReloadAssemblies(bool softReload);+ private static partial void godot_icall_Internal_ReloadAssemblies();private static partial void godot_icall_Internal_EditorDebuggerNodeReloadScripts();diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cppindex c3c2ba24bd4..5a06f97b089 100644--- a/modules/mono/editor/editor_internal_calls.cpp+++ b/modules/mono/editor/editor_internal_calls.cpp@@ -152,9 +152,9 @@ bool godot_icall_Internal_IsAssembliesReloadingNeeded() {#endif}-void godot_icall_Internal_ReloadAssemblies(bool p_soft_reload) {+void godot_icall_Internal_ReloadAssemblies() {#ifdef GD_MONO_HOT_RELOAD- callable_mp(MonoBind::GodotSharp::get_singleton(), &MonoBind::GodotSharp::reload_assemblies).call_deferred(p_soft_reload);+ callable_mp(MonoBind::GodotSharp::get_singleton(), &MonoBind::GodotSharp::reload_assemblies).call_deferred();#endif}diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cppindex 8805ab6f0a4..5b9b213ea0e 100644--- a/modules/mono/mono_gd/gd_mono.cpp+++ b/modules/mono/mono_gd/gd_mono.cpp@@ -856,13 +856,13 @@ namespace MonoBind {GodotSharp *GodotSharp::singleton = nullptr;-void GodotSharp::reload_assemblies(bool p_soft_reload) {+void GodotSharp::reload_assemblies() {#ifdef GD_MONO_HOT_RELOADCRASH_COND(CSharpLanguage::get_singleton() == nullptr);// This method may be called more than once with `call_deferred`, so we need to check// again if reloading is needed to avoid reloading multiple times unnecessarily.if (CSharpLanguage::get_singleton()->is_assembly_reloading_needed()) {- CSharpLanguage::get_singleton()->reload_assemblies(p_soft_reload);+ CSharpLanguage::get_singleton()->reload_assemblies();}#endif}diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.hindex b03ca49960e..b83df7c67f2 100644--- a/modules/mono/mono_gd/gd_mono.h+++ b/modules/mono/mono_gd/gd_mono.h@@ -163,7 +163,7 @@ protected:public:static GodotSharp *get_singleton() { return singleton; }- void reload_assemblies(bool p_soft_reload);+ void reload_assemblies();GodotSharp();~GodotSharp();