diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/register_scene_types.cpp | 68 | ||||
-rw-r--r-- | scene/resources/dynamic_font.h | 1 | ||||
-rw-r--r-- | scene/resources/dynamic_font_stb.h | 1 | ||||
-rw-r--r-- | scene/resources/font.h | 1 | ||||
-rw-r--r-- | scene/resources/scene_format_text.h | 3 | ||||
-rw-r--r-- | scene/resources/shader.h | 2 | ||||
-rw-r--r-- | scene/resources/texture.h | 2 |
7 files changed, 48 insertions, 30 deletions
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index d7750c91ef..ae6211a3df 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -210,18 +210,18 @@ #include "scene/resources/physics_material.h" #endif -static ResourceFormatSaverText *resource_saver_text = NULL; -static ResourceFormatLoaderText *resource_loader_text = NULL; +static Ref<ResourceFormatSaverText> resource_saver_text; +static Ref<ResourceFormatLoaderText> resource_loader_text; -static ResourceFormatLoaderDynamicFont *resource_loader_dynamic_font = NULL; +static Ref<ResourceFormatLoaderDynamicFont> resource_loader_dynamic_font; -static ResourceFormatLoaderStreamTexture *resource_loader_stream_texture = NULL; -static ResourceFormatLoaderTextureLayered *resource_loader_texture_layered = NULL; +static Ref<ResourceFormatLoaderStreamTexture> resource_loader_stream_texture; +static Ref<ResourceFormatLoaderTextureLayered> resource_loader_texture_layered; -static ResourceFormatLoaderBMFont *resource_loader_bmfont = NULL; +static Ref<ResourceFormatLoaderBMFont> resource_loader_bmfont; -static ResourceFormatSaverShader *resource_saver_shader = NULL; -static ResourceFormatLoaderShader *resource_loader_shader = NULL; +static Ref<ResourceFormatSaverShader> resource_saver_shader; +static Ref<ResourceFormatLoaderShader> resource_loader_shader; void register_scene_types() { @@ -231,28 +231,28 @@ void register_scene_types() { Node::init_node_hrcr(); - resource_loader_dynamic_font = memnew(ResourceFormatLoaderDynamicFont); + resource_loader_dynamic_font.instance(); ResourceLoader::add_resource_format_loader(resource_loader_dynamic_font); - resource_loader_stream_texture = memnew(ResourceFormatLoaderStreamTexture); + resource_loader_stream_texture.instance(); ResourceLoader::add_resource_format_loader(resource_loader_stream_texture); - resource_loader_texture_layered = memnew(ResourceFormatLoaderTextureLayered); + resource_loader_texture_layered.instance(); ResourceLoader::add_resource_format_loader(resource_loader_texture_layered); - resource_saver_text = memnew(ResourceFormatSaverText); + resource_saver_text.instance(); ResourceSaver::add_resource_format_saver(resource_saver_text, true); - resource_loader_text = memnew(ResourceFormatLoaderText); + resource_loader_text.instance(); ResourceLoader::add_resource_format_loader(resource_loader_text, true); - resource_saver_shader = memnew(ResourceFormatSaverShader); + resource_saver_shader.instance(); ResourceSaver::add_resource_format_saver(resource_saver_shader, true); - resource_loader_shader = memnew(ResourceFormatLoaderShader); + resource_loader_shader.instance(); ResourceLoader::add_resource_format_loader(resource_loader_shader, true); - resource_loader_bmfont = memnew(ResourceFormatLoaderBMFont); + resource_loader_bmfont.instance(); ResourceLoader::add_resource_format_loader(resource_loader_bmfont, true); OS::get_singleton()->yield(); //may take time to init @@ -735,27 +735,37 @@ void unregister_scene_types() { clear_default_theme(); - memdelete(resource_loader_dynamic_font); - memdelete(resource_loader_stream_texture); - memdelete(resource_loader_texture_layered); + ResourceLoader::remove_resource_format_loader(resource_loader_dynamic_font); + resource_loader_dynamic_font.unref(); + + ResourceLoader::remove_resource_format_loader(resource_loader_texture_layered); + resource_loader_texture_layered.unref(); + + ResourceLoader::remove_resource_format_loader(resource_loader_stream_texture); + resource_loader_stream_texture.unref(); DynamicFont::finish_dynamic_fonts(); - if (resource_saver_text) { - memdelete(resource_saver_text); + if (resource_saver_text.is_valid()) { + ResourceSaver::remove_resource_format_saver(resource_saver_text); + resource_saver_text.unref(); } - if (resource_loader_text) { - memdelete(resource_loader_text); + if (resource_loader_text.is_valid()) { + ResourceLoader::remove_resource_format_loader(resource_loader_text); + resource_loader_text.unref(); } - if (resource_saver_shader) { - memdelete(resource_saver_shader); + if (resource_saver_shader.is_valid()) { + ResourceSaver::remove_resource_format_saver(resource_saver_shader); + resource_saver_shader.unref(); } - if (resource_loader_shader) { - memdelete(resource_loader_shader); + if (resource_loader_shader.is_valid()) { + ResourceLoader::remove_resource_format_loader(resource_loader_shader); + resource_loader_shader.unref(); } - if (resource_loader_bmfont) { - memdelete(resource_loader_bmfont); + if (resource_loader_bmfont.is_valid()) { + ResourceLoader::remove_resource_format_loader(resource_loader_bmfont); + resource_loader_bmfont.unref(); } SpatialMaterial::finish_shaders(); diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index 96437e8982..9c41c948bd 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -303,6 +303,7 @@ VARIANT_ENUM_CAST(DynamicFont::SpacingType); ///////////// class ResourceFormatLoaderDynamicFont : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderDynamicFont, ResourceFormatLoader) public: virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); virtual void get_recognized_extensions(List<String> *p_extensions) const; diff --git a/scene/resources/dynamic_font_stb.h b/scene/resources/dynamic_font_stb.h index e1ef72ea4f..c83cc1b01f 100644 --- a/scene/resources/dynamic_font_stb.h +++ b/scene/resources/dynamic_font_stb.h @@ -180,6 +180,7 @@ public: ///////////// class ResourceFormatLoaderDynamicFont : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderDynamicFont, ResourceFormatLoader) public: virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); virtual void get_recognized_extensions(List<String> *p_extensions) const; diff --git a/scene/resources/font.h b/scene/resources/font.h index 39e66a822d..3c5e650758 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -201,6 +201,7 @@ public: }; class ResourceFormatLoaderBMFont : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderBMFont, ResourceFormatLoader) public: virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); virtual void get_recognized_extensions(List<String> *p_extensions) const; diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h index 8d1af2bbb2..e5ee6ae760 100644 --- a/scene/resources/scene_format_text.h +++ b/scene/resources/scene_format_text.h @@ -128,7 +128,7 @@ public: }; class ResourceFormatLoaderText : public ResourceFormatLoader { - + GDCLASS(ResourceFormatLoaderText, ResourceFormatLoader) public: static ResourceFormatLoaderText *singleton; virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); @@ -170,6 +170,7 @@ public: }; class ResourceFormatSaverText : public ResourceFormatSaver { + GDCLASS(ResourceFormatSaverText, ResourceFormatSaver) public: static ResourceFormatSaverText *singleton; virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); diff --git a/scene/resources/shader.h b/scene/resources/shader.h index c2c205237f..6804832fb9 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -100,6 +100,7 @@ public: VARIANT_ENUM_CAST(Shader::Mode); class ResourceFormatLoaderShader : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderShader, ResourceFormatLoader) public: virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); virtual void get_recognized_extensions(List<String> *p_extensions) const; @@ -108,6 +109,7 @@ public: }; class ResourceFormatSaverShader : public ResourceFormatSaver { + GDCLASS(ResourceFormatSaverShader, ResourceFormatSaver) public: virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const; diff --git a/scene/resources/texture.h b/scene/resources/texture.h index e9b69e9cb1..845a075015 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -236,6 +236,7 @@ public: }; class ResourceFormatLoaderStreamTexture : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderStreamTexture, ResourceFormatLoader) public: virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); virtual void get_recognized_extensions(List<String> *p_extensions) const; @@ -489,6 +490,7 @@ public: }; class ResourceFormatLoaderTextureLayered : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderTextureLayered, ResourceFormatLoader) public: enum Compression { COMPRESSION_LOSSLESS, |