|
|
@@ -212,7 +212,7 @@ void GDScriptCache::remove_script(const String &p_path) {
|
|
|
Ref<GDScriptParserRef> GDScriptCache::get_parser(const String &p_path, GDScriptParserRef::Status p_status, Error &r_error, const String &p_owner) {
|
|
|
MutexLock lock(singleton->mutex);
|
|
|
Ref<GDScriptParserRef> ref;
|
|
|
- if (!p_owner.is_empty()) {
|
|
|
+ if (!p_owner.is_empty() && p_path != p_owner) {
|
|
|
singleton->dependencies[p_owner].insert(p_path);
|
|
|
singleton->parser_inverse_dependencies[p_path].insert(p_owner);
|
|
|
}
|
|
|
@@ -298,7 +298,7 @@ Vector<uint8_t> GDScriptCache::get_binary_tokens(const String &p_path) {
|
|
|
Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, Error &r_error, const String &p_owner) {
|
|
|
MutexLock lock(singleton->mutex);
|
|
|
|
|
|
- if (!p_owner.is_empty()) {
|
|
|
+ if (!p_owner.is_empty() && p_path != p_owner) {
|
|
|
singleton->dependencies[p_owner].insert(p_path);
|
|
|
}
|
|
|
if (singleton->full_gdscript_cache.has(p_path)) {
|
|
|
@@ -312,7 +312,8 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, Error &r_e
|
|
|
|
|
|
Ref<GDScript> script;
|
|
|
script.instantiate();
|
|
|
- script->set_path(p_path, true);
|
|
|
+
|
|
|
+ script->set_path_cache(p_path);
|
|
|
if (remapped_path.has_extension("gdc")) {
|
|
|
Vector<uint8_t> buffer = get_binary_tokens(remapped_path);
|
|
|
if (buffer.is_empty()) {
|
|
|
@@ -338,9 +339,20 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, Error &r_e
|
|
|
}
|
|
|
|
|
|
Ref<GDScript> GDScriptCache::get_full_script(const String &p_path, Error &r_error, const String &p_owner, bool p_update_from_disk) {
|
|
|
+ Ref<GDScript> uncached_script = get_full_script_no_resource_cache(p_path, r_error, p_owner, p_update_from_disk);
|
|
|
+
|
|
|
+ // Resources don't know whether they are cached, so using `set_path()` after `set_path_cache()` does not add the resource to the cache if the path is the same.
|
|
|
+ // We reset the cached path from `get_shallow_script()` so that the subsequent call to `set_path()` caches everything correctly.
|
|
|
+ uncached_script->set_path_cache(String());
|
|
|
+ uncached_script->set_path(p_path, true);
|
|
|
+
|
|
|
+ return uncached_script;
|
|
|
+}
|
|
|
+
|
|
|
+Ref<GDScript> GDScriptCache::get_full_script_no_resource_cache(const String &p_path, Error &r_error, const String &p_owner, bool p_update_from_disk) {
|
|
|
MutexLock lock(singleton->mutex);
|
|
|
|
|
|
- if (!p_owner.is_empty()) {
|
|
|
+ if (!p_owner.is_empty() && p_path != p_owner) {
|
|
|
singleton->dependencies[p_owner].insert(p_path);
|
|
|
}
|
|
|
|