From d531869a7c3c73d79c6ead71c7736f285bf6e1a1 Mon Sep 17 00:00:00 2001 From: rune-scape Date: Thu, 1 Dec 2022 05:20:42 -0500 Subject: GDScript: Fix subclass script path issues --- modules/gdscript/gdscript.cpp | 18 ++++++++++++------ modules/gdscript/gdscript.h | 3 ++- modules/gdscript/gdscript_analyzer.cpp | 10 +++++----- modules/gdscript/gdscript_byte_codegen.cpp | 2 +- modules/gdscript/gdscript_compiler.cpp | 4 ++-- modules/gdscript/gdscript_utility_functions.cpp | 5 +++-- modules/gdscript/gdscript_vm.cpp | 2 +- 7 files changed, 26 insertions(+), 18 deletions(-) (limited to 'modules/gdscript') diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 60230257e0..9c53855d37 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -478,7 +478,7 @@ void GDScript::_clear_doc() { void GDScript::_update_doc() { _clear_doc(); - doc.script_path = "\"" + get_path().get_slice("://", 1) + "\""; + doc.script_path = vformat(R"("%s")", get_script_path().get_slice("://", 1)); if (!name.is_empty()) { doc.name = name; } else { @@ -801,9 +801,9 @@ void GDScript::update_exports() { String GDScript::_get_debug_path() const { if (is_built_in() && !get_name().is_empty()) { - return get_name() + " (" + get_path() + ")"; + return vformat("%s(%s)", get_name(), get_script_path()); } else { - return get_path(); + return get_script_path(); } } @@ -904,7 +904,7 @@ Error GDScript::reload(bool p_keep_state) { for (const GDScriptWarning &warning : parser.get_warnings()) { if (EngineDebugger::is_active()) { Vector si; - EngineDebugger::get_script_debugger()->send_error("", get_path(), warning.start_line, warning.get_name(), warning.get_message(), false, ERR_HANDLER_WARNING, si); + EngineDebugger::get_script_debugger()->send_error("", get_script_path(), warning.start_line, warning.get_name(), warning.get_message(), false, ERR_HANDLER_WARNING, si); } } #endif @@ -1027,6 +1027,10 @@ void GDScript::set_path(const String &p_path, bool p_take_over) { } } +String GDScript::get_script_path() const { + return path; +} + Error GDScript::load_source_code(const String &p_path) { if (p_path.is_empty() || ResourceLoader::get_resource_type(p_path.get_slice("::", 0)) == "PackedScene") { return OK; @@ -2128,7 +2132,8 @@ void GDScriptLanguage::reload_all_scripts() { SelfList *elem = script_list.first(); while (elem) { - if (elem->self()->get_path().is_resource_file()) { + // Scripts will reload all subclasses, so only reload root scripts. + if (elem->self()->is_root_script() && elem->self()->get_path().is_resource_file()) { print_verbose("GDScript: Found: " + elem->self()->get_path()); scripts.push_back(Ref(elem->self())); //cast to gdscript to avoid being erased by accident } @@ -2157,7 +2162,8 @@ void GDScriptLanguage::reload_tool_script(const Ref