mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Prevent shallow scripts from leaking into the ResourceCache
Co-Authored-By: Moritz Burgdorff <mburgdorff@outlook.com> Co-Authored-By: Lily <gofastlily@gmail.com>
This commit is contained in:
@@ -78,6 +78,12 @@ public:
|
||||
~GDScriptParserRef();
|
||||
};
|
||||
|
||||
#ifdef TESTS_ENABLED
|
||||
namespace GDScriptTests {
|
||||
class TestGDScriptCacheAccessor;
|
||||
}
|
||||
#endif // TESTS_ENABLED
|
||||
|
||||
class GDScriptCache {
|
||||
// String key is full path.
|
||||
HashMap<String, GDScriptParserRef *> parser_map;
|
||||
@@ -91,6 +97,9 @@ class GDScriptCache {
|
||||
friend class GDScript;
|
||||
friend class GDScriptParserRef;
|
||||
friend class GDScriptInstance;
|
||||
#ifdef TESTS_ENABLED
|
||||
friend class GDScriptTests::TestGDScriptCacheAccessor;
|
||||
#endif // TESTS_ENABLED
|
||||
|
||||
static GDScriptCache *singleton;
|
||||
|
||||
@@ -112,6 +121,19 @@ public:
|
||||
static String get_source_code(const String &p_path);
|
||||
static Vector<uint8_t> get_binary_tokens(const String &p_path);
|
||||
static Ref<GDScript> get_shallow_script(const String &p_path, Error &r_error, const String &p_owner = String());
|
||||
/**
|
||||
* Returns a fully loaded GDScript using an already cached script if one exists.
|
||||
*
|
||||
* If a new script is created, the resource will only have its patch_cache set, so it won't be present in the ResourceCache.
|
||||
* Mismatches between GDScriptCache and ResourceCache might trigger complex issues so when using this method ensure
|
||||
* that the script is added to the resource cache or removed from the GDScript cache.
|
||||
*/
|
||||
static Ref<GDScript> get_full_script_no_resource_cache(const String &p_path, Error &r_error, const String &p_owner = String(), bool p_update_from_disk = false);
|
||||
/**
|
||||
* Returns a fully loaded GDScript using an already cached script if one exists.
|
||||
*
|
||||
* The returned instance is present in GDScriptCache and ResourceCache.
|
||||
*/
|
||||
static Ref<GDScript> get_full_script(const String &p_path, Error &r_error, const String &p_owner = String(), bool p_update_from_disk = false);
|
||||
static Ref<GDScript> get_cached_script(const String &p_path);
|
||||
static Error finish_compiling(const String &p_owner);
|
||||
|
||||
Reference in New Issue
Block a user