mirror of https://github.com/godotengine/godot
Fix built-in script live reloading
This commit is contained in:
parent
78d91947f6
commit
ad4fb8c1df
|
|
@ -681,7 +681,15 @@ void RemoteDebugger::poll_events(bool p_is_idle) {
|
||||||
for (const Variant &v : script_paths_to_reload) {
|
for (const Variant &v : script_paths_to_reload) {
|
||||||
const String &path = v;
|
const String &path = v;
|
||||||
Error err = OK;
|
Error err = OK;
|
||||||
Ref<Script> script = ResourceLoader::load(path, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
|
Ref<Script> script = ResourceCache::get_ref(path);
|
||||||
|
if (script.is_null()) {
|
||||||
|
if (path.is_resource_file()) {
|
||||||
|
script = ResourceLoader::load(path, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
|
||||||
|
} else {
|
||||||
|
// Built-in script that isn't in ResourceCache, no need to reload.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
ERR_CONTINUE_MSG(err != OK, vformat("Could not reload script '%s': %s", path, error_names[err]));
|
ERR_CONTINUE_MSG(err != OK, vformat("Could not reload script '%s': %s", path, error_names[err]));
|
||||||
ERR_CONTINUE_MSG(script.is_null(), vformat("Could not reload script '%s': Not a script!", path, error_names[err]));
|
ERR_CONTINUE_MSG(script.is_null(), vformat("Could not reload script '%s': Not a script!", path, error_names[err]));
|
||||||
scripts_to_reload.push_back(script);
|
scripts_to_reload.push_back(script);
|
||||||
|
|
|
||||||
|
|
@ -1119,14 +1119,14 @@ void ScriptEditor::_mark_built_in_scripts_as_saved(const String &p_parent_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Resource> edited_res = se->get_edited_resource();
|
Ref<Resource> edited_res = se->get_edited_resource();
|
||||||
|
|
||||||
if (!edited_res->is_built_in()) {
|
if (!edited_res->is_built_in()) {
|
||||||
continue; // External script, who cares.
|
continue; // External script, who cares.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (edited_res->get_path().get_slice("::", 0) == p_parent_path) {
|
if (edited_res->get_path().get_slice("::", 0) != p_parent_path) {
|
||||||
se->tag_saved_version();
|
continue; // Wrong scene.
|
||||||
}
|
}
|
||||||
|
se->tag_saved_version();
|
||||||
|
|
||||||
Ref<Script> scr = edited_res;
|
Ref<Script> scr = edited_res;
|
||||||
if (scr.is_valid()) {
|
if (scr.is_valid()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue