diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-12-16 14:26:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-16 14:26:56 +0100 |
commit | 9df7ed59fb39e38db30326365adc18afb79903bb (patch) | |
tree | 59d2220e78fe5295dd6ac4aa5607da6501a96eb6 /modules | |
parent | 3914bdb82eafa558bc1512c7cf3c4f77565d0847 (diff) | |
parent | 065e2670af53ae2f71b78d57f8a217b4539cbbe2 (diff) |
Merge pull request #19501 from Zylann/custom_loaders
Added basic support for custom resource savers and loaders
Diffstat (limited to 'modules')
25 files changed, 104 insertions, 57 deletions
diff --git a/modules/dds/register_types.cpp b/modules/dds/register_types.cpp index d6351fb6fe..94f0ebfd5f 100644 --- a/modules/dds/register_types.cpp +++ b/modules/dds/register_types.cpp @@ -32,15 +32,16 @@ #include "texture_loader_dds.h" -static ResourceFormatDDS *resource_loader_dds = NULL; +static Ref<ResourceFormatDDS> resource_loader_dds; void register_dds_types() { - resource_loader_dds = memnew(ResourceFormatDDS); + resource_loader_dds.instance(); ResourceLoader::add_resource_format_loader(resource_loader_dds); } void unregister_dds_types() { - memdelete(resource_loader_dds); + ResourceLoader::remove_resource_format_loader(resource_loader_dds); + resource_loader_dds.unref(); } diff --git a/modules/dds/texture_loader_dds.h b/modules/dds/texture_loader_dds.h index 4e2593c744..abd747f63e 100644 --- a/modules/dds/texture_loader_dds.h +++ b/modules/dds/texture_loader_dds.h @@ -35,6 +35,7 @@ #include "scene/resources/texture.h" class ResourceFormatDDS : public ResourceFormatLoader { + GDCLASS(ResourceFormatDDS, 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/modules/etc/register_types.cpp b/modules/etc/register_types.cpp index 1d1f0e1b77..301193874d 100644 --- a/modules/etc/register_types.cpp +++ b/modules/etc/register_types.cpp @@ -33,11 +33,11 @@ #include "image_etc.h" #include "texture_loader_pkm.h" -static ResourceFormatPKM *resource_loader_pkm = NULL; +static Ref<ResourceFormatPKM> resource_loader_pkm; void register_etc_types() { - resource_loader_pkm = memnew(ResourceFormatPKM); + resource_loader_pkm.instance(); ResourceLoader::add_resource_format_loader(resource_loader_pkm); _register_etc_compress_func(); @@ -45,5 +45,6 @@ void register_etc_types() { void unregister_etc_types() { - memdelete(resource_loader_pkm); + ResourceLoader::remove_resource_format_loader(resource_loader_pkm); + resource_loader_pkm.unref(); } diff --git a/modules/etc/texture_loader_pkm.h b/modules/etc/texture_loader_pkm.h index b5a95767c7..8308b84109 100644 --- a/modules/etc/texture_loader_pkm.h +++ b/modules/etc/texture_loader_pkm.h @@ -35,6 +35,7 @@ #include "scene/resources/texture.h" class ResourceFormatPKM : public ResourceFormatLoader { + GDCLASS(ResourceFormatPKM, 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/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index c5364a72ac..528344a814 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -161,6 +161,7 @@ public: }; class GDNativeLibraryResourceLoader : public ResourceFormatLoader { + GDCLASS(GDNativeLibraryResourceLoader, ResourceFormatLoader) public: virtual RES load(const String &p_path, const String &p_original_path, Error *r_error); virtual void get_recognized_extensions(List<String> *p_extensions) const; @@ -169,6 +170,7 @@ public: }; class GDNativeLibraryResourceSaver : public ResourceFormatSaver { + GDCLASS(GDNativeLibraryResourceSaver, ResourceFormatSaver) public: virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags); virtual bool recognize(const RES &p_resource) const; diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index e6f3c06ee5..67fb54387d 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -380,6 +380,7 @@ public: }; class ResourceFormatLoaderNativeScript : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderNativeScript, 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; @@ -388,6 +389,7 @@ public: }; class ResourceFormatSaverNativeScript : public ResourceFormatSaver { + GDCLASS(ResourceFormatSaverNativeScript, ResourceFormatSaver) virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); virtual bool recognize(const RES &p_resource) const; virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const; diff --git a/modules/gdnative/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp index 4433c0a638..1e0c3d9fd8 100644 --- a/modules/gdnative/nativescript/register_types.cpp +++ b/modules/gdnative/nativescript/register_types.cpp @@ -39,8 +39,8 @@ NativeScriptLanguage *native_script_language; -ResourceFormatLoaderNativeScript *resource_loader_gdns = NULL; -ResourceFormatSaverNativeScript *resource_saver_gdns = NULL; +Ref<ResourceFormatLoaderNativeScript> resource_loader_gdns; +Ref<ResourceFormatSaverNativeScript> resource_saver_gdns; void register_nativescript_types() { native_script_language = memnew(NativeScriptLanguage); @@ -50,18 +50,20 @@ void register_nativescript_types() { native_script_language->set_language_index(ScriptServer::get_language_count()); ScriptServer::register_language(native_script_language); - resource_saver_gdns = memnew(ResourceFormatSaverNativeScript); + resource_saver_gdns.instance(); ResourceSaver::add_resource_format_saver(resource_saver_gdns); - resource_loader_gdns = memnew(ResourceFormatLoaderNativeScript); + resource_loader_gdns.instance(); ResourceLoader::add_resource_format_loader(resource_loader_gdns); } void unregister_nativescript_types() { - memdelete(resource_loader_gdns); + ResourceLoader::remove_resource_format_loader(resource_loader_gdns); + resource_loader_gdns.unref(); - memdelete(resource_saver_gdns); + ResourceSaver::remove_resource_format_saver(resource_saver_gdns); + resource_saver_gdns.unref(); if (native_script_language) { ScriptServer::unregister_language(native_script_language); diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp index 2b538c4a36..0cda8859dd 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.cpp +++ b/modules/gdnative/pluginscript/pluginscript_language.cpp @@ -417,8 +417,8 @@ void PluginScriptLanguage::unlock() { PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_desc *desc) : _desc(*desc) { - _resource_loader = memnew(ResourceFormatLoaderPluginScript(this)); - _resource_saver = memnew(ResourceFormatSaverPluginScript(this)); + _resource_loader = Ref<ResourceFormatLoaderPluginScript>(memnew(ResourceFormatLoaderPluginScript(this))); + _resource_saver = Ref<ResourceFormatSaverPluginScript>(memnew(ResourceFormatSaverPluginScript(this))); // TODO: totally remove _lock attribute if NO_THREADS is set #ifdef NO_THREADS @@ -429,8 +429,6 @@ PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_des } PluginScriptLanguage::~PluginScriptLanguage() { - memdelete(_resource_loader); - memdelete(_resource_saver); #ifndef NO_THREADS if (_lock) { memdelete(_lock); diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h index c4df6f3a33..f749e900f5 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.h +++ b/modules/gdnative/pluginscript/pluginscript_language.h @@ -48,8 +48,8 @@ class PluginScriptLanguage : public ScriptLanguage { friend class PluginScript; friend class PluginScriptInstance; - ResourceFormatLoaderPluginScript *_resource_loader; - ResourceFormatSaverPluginScript *_resource_saver; + Ref<ResourceFormatLoaderPluginScript> _resource_loader; + Ref<ResourceFormatSaverPluginScript> _resource_saver; const godot_pluginscript_language_desc _desc; godot_pluginscript_language_data *_data; @@ -59,8 +59,8 @@ class PluginScriptLanguage : public ScriptLanguage { public: virtual String get_name() const; - _FORCE_INLINE_ ResourceFormatLoaderPluginScript *get_resource_loader() { return _resource_loader; }; - _FORCE_INLINE_ ResourceFormatSaverPluginScript *get_resource_saver() { return _resource_saver; }; + _FORCE_INLINE_ Ref<ResourceFormatLoaderPluginScript> get_resource_loader() { return _resource_loader; } + _FORCE_INLINE_ Ref<ResourceFormatSaverPluginScript> get_resource_saver() { return _resource_saver; } /* LANGUAGE FUNCTIONS */ virtual void init(); diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h index 5c17bb932e..ee9869be84 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.h +++ b/modules/gdnative/pluginscript/pluginscript_loader.h @@ -39,6 +39,9 @@ class PluginScriptLanguage; class ResourceFormatLoaderPluginScript : public ResourceFormatLoader { + + GDCLASS(ResourceFormatLoaderPluginScript, ResourceFormatLoader) + PluginScriptLanguage *_language; public: @@ -50,6 +53,9 @@ public: }; class ResourceFormatSaverPluginScript : public ResourceFormatSaver { + + GDCLASS(ResourceFormatSaverPluginScript, ResourceFormatSaver) + PluginScriptLanguage *_language; public: diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index 62e87c3651..51f0b9afcc 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -299,8 +299,8 @@ GDNativeCallRegistry *GDNativeCallRegistry::singleton; Vector<Ref<GDNative> > singleton_gdnatives; -GDNativeLibraryResourceLoader *resource_loader_gdnlib = NULL; -GDNativeLibraryResourceSaver *resource_saver_gdnlib = NULL; +Ref<GDNativeLibraryResourceLoader> resource_loader_gdnlib; +Ref<GDNativeLibraryResourceSaver> resource_saver_gdnlib; void register_gdnative_types() { @@ -312,8 +312,8 @@ void register_gdnative_types() { ClassDB::register_class<GDNativeLibrary>(); ClassDB::register_class<GDNative>(); - resource_loader_gdnlib = memnew(GDNativeLibraryResourceLoader); - resource_saver_gdnlib = memnew(GDNativeLibraryResourceSaver); + resource_loader_gdnlib.instance(); + resource_saver_gdnlib.instance(); ResourceLoader::add_resource_format_loader(resource_loader_gdnlib); ResourceSaver::add_resource_format_saver(resource_saver_gdnlib); @@ -391,8 +391,11 @@ void unregister_gdnative_types() { } #endif - memdelete(resource_loader_gdnlib); - memdelete(resource_saver_gdnlib); + ResourceLoader::remove_resource_format_loader(resource_loader_gdnlib); + ResourceSaver::remove_resource_format_saver(resource_saver_gdnlib); + + resource_loader_gdnlib.unref(); + resource_saver_gdnlib.unref(); // This is for printing out the sizes of the core types diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 752d660ffb..3e7cb076aa 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -500,6 +500,7 @@ public: }; class ResourceFormatLoaderGDScript : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderGDScript, 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; @@ -508,6 +509,7 @@ public: }; class ResourceFormatSaverGDScript : public ResourceFormatSaver { + GDCLASS(ResourceFormatSaverGDScript, 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/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index 26dcbdcf89..9c4dc0c926 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -38,8 +38,8 @@ #include "gdscript_tokenizer.h" GDScriptLanguage *script_language_gd = NULL; -ResourceFormatLoaderGDScript *resource_loader_gd = NULL; -ResourceFormatSaverGDScript *resource_saver_gd = NULL; +Ref<ResourceFormatLoaderGDScript> resource_loader_gd; +Ref<ResourceFormatSaverGDScript> resource_saver_gd; #ifdef TOOLS_ENABLED @@ -87,9 +87,11 @@ void register_gdscript_types() { script_language_gd = memnew(GDScriptLanguage); ScriptServer::register_language(script_language_gd); - resource_loader_gd = memnew(ResourceFormatLoaderGDScript); + + resource_loader_gd.instance(); ResourceLoader::add_resource_format_loader(resource_loader_gd); - resource_saver_gd = memnew(ResourceFormatSaverGDScript); + + resource_saver_gd.instance(); ResourceSaver::add_resource_format_saver(resource_saver_gd); #ifdef TOOLS_ENABLED @@ -104,8 +106,14 @@ void unregister_gdscript_types() { if (script_language_gd) memdelete(script_language_gd); - if (resource_loader_gd) - memdelete(resource_loader_gd); - if (resource_saver_gd) - memdelete(resource_saver_gd); + + if (resource_loader_gd.is_valid()) { + ResourceLoader::remove_resource_format_loader(resource_loader_gd); + resource_loader_gd.unref(); + } + + if (resource_saver_gd.is_valid()) { + ResourceSaver::remove_resource_format_saver(resource_saver_gd); + resource_saver_gd.unref(); + } } diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 08466bae58..695889b2a8 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -398,6 +398,7 @@ public: }; class ResourceFormatLoaderCSharpScript : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderCSharpScript, 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; @@ -406,6 +407,7 @@ public: }; class ResourceFormatSaverCSharpScript : public ResourceFormatSaver { + GDCLASS(ResourceFormatSaverCSharpScript, 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/modules/mono/register_types.cpp b/modules/mono/register_types.cpp index f6cb143e8e..9ee7a0b5c4 100644 --- a/modules/mono/register_types.cpp +++ b/modules/mono/register_types.cpp @@ -35,8 +35,8 @@ #include "csharp_script.h" CSharpLanguage *script_language_cs = NULL; -ResourceFormatLoaderCSharpScript *resource_loader_cs = NULL; -ResourceFormatSaverCSharpScript *resource_saver_cs = NULL; +Ref<ResourceFormatLoaderCSharpScript> resource_loader_cs; +Ref<ResourceFormatSaverCSharpScript> resource_saver_cs; _GodotSharp *_godotsharp = NULL; @@ -52,9 +52,10 @@ void register_mono_types() { script_language_cs->set_language_index(ScriptServer::get_language_count()); ScriptServer::register_language(script_language_cs); - resource_loader_cs = memnew(ResourceFormatLoaderCSharpScript); + resource_loader_cs.instance(); ResourceLoader::add_resource_format_loader(resource_loader_cs); - resource_saver_cs = memnew(ResourceFormatSaverCSharpScript); + + resource_saver_cs.instance(); ResourceSaver::add_resource_format_saver(resource_saver_cs); } @@ -63,10 +64,16 @@ void unregister_mono_types() { if (script_language_cs) memdelete(script_language_cs); - if (resource_loader_cs) - memdelete(resource_loader_cs); - if (resource_saver_cs) - memdelete(resource_saver_cs); + + if (resource_loader_cs.is_valid()) { + ResourceLoader::remove_resource_format_loader(resource_loader_cs); + resource_loader_cs.unref(); + } + + if (resource_saver_cs.is_valid()) { + ResourceSaver::remove_resource_format_saver(resource_saver_cs); + resource_saver_cs.unref(); + } if (_godotsharp) memdelete(_godotsharp); diff --git a/modules/opus/audio_stream_opus.h b/modules/opus/audio_stream_opus.h index c004adeb77..c962936238 100644 --- a/modules/opus/audio_stream_opus.h +++ b/modules/opus/audio_stream_opus.h @@ -132,6 +132,7 @@ public: }; class ResourceFormatLoaderAudioStreamOpus : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderAudioStreamOpus, 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/modules/opus/register_types.cpp b/modules/opus/register_types.cpp index f34555841e..3367fc1090 100644 --- a/modules/opus/register_types.cpp +++ b/modules/opus/register_types.cpp @@ -32,7 +32,7 @@ #include "audio_stream_opus.h" -static ResourceFormatLoaderAudioStreamOpus *opus_stream_loader = NULL; +static Ref<ResourceFormatLoaderAudioStreamOpus> opus_stream_loader; void register_opus_types() { // Sorry guys, do not enable this unless you can figure out a way diff --git a/modules/pvr/register_types.cpp b/modules/pvr/register_types.cpp index 0991828ef2..cf5bdabf3f 100644 --- a/modules/pvr/register_types.cpp +++ b/modules/pvr/register_types.cpp @@ -32,15 +32,16 @@ #include "texture_loader_pvr.h" -static ResourceFormatPVR *resource_loader_pvr = NULL; +static Ref<ResourceFormatPVR> resource_loader_pvr; void register_pvr_types() { - resource_loader_pvr = memnew(ResourceFormatPVR); + resource_loader_pvr.instance(); ResourceLoader::add_resource_format_loader(resource_loader_pvr); } void unregister_pvr_types() { - memdelete(resource_loader_pvr); + ResourceLoader::remove_resource_format_loader(resource_loader_pvr); + resource_loader_pvr.unref(); } diff --git a/modules/pvr/texture_loader_pvr.h b/modules/pvr/texture_loader_pvr.h index c859a4cdda..530b6948f0 100644 --- a/modules/pvr/texture_loader_pvr.h +++ b/modules/pvr/texture_loader_pvr.h @@ -35,6 +35,7 @@ #include "scene/resources/texture.h" class ResourceFormatPVR : public ResourceFormatLoader { + GDCLASS(ResourceFormatPVR, 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/modules/theora/register_types.cpp b/modules/theora/register_types.cpp index 971fe39c44..3da721c6a0 100644 --- a/modules/theora/register_types.cpp +++ b/modules/theora/register_types.cpp @@ -32,11 +32,11 @@ #include "video_stream_theora.h" -static ResourceFormatLoaderTheora *resource_loader_theora = NULL; +static Ref<ResourceFormatLoaderTheora> resource_loader_theora; void register_theora_types() { - resource_loader_theora = memnew(ResourceFormatLoaderTheora); + resource_loader_theora.instance(); ResourceLoader::add_resource_format_loader(resource_loader_theora, true); ClassDB::register_class<VideoStreamTheora>(); @@ -44,7 +44,9 @@ void register_theora_types() { void unregister_theora_types() { - if (resource_loader_theora) { - memdelete(resource_loader_theora); + ResourceLoader::remove_resource_format_loader(resource_loader_theora); + + if (resource_loader_theora.is_valid()) { + resource_loader_theora.unref(); } } diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h index 4be723f85b..c9629fbf9f 100644 --- a/modules/theora/video_stream_theora.h +++ b/modules/theora/video_stream_theora.h @@ -186,6 +186,7 @@ public: }; class ResourceFormatLoaderTheora : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderTheora, 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/modules/vorbis/audio_stream_ogg_vorbis.h b/modules/vorbis/audio_stream_ogg_vorbis.h index 73c4b5f3f4..7683f38991 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.h +++ b/modules/vorbis/audio_stream_ogg_vorbis.h @@ -127,6 +127,7 @@ public: }; class ResourceFormatLoaderAudioStreamOGGVorbis : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderAudioStreamOGGVorbis, 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/modules/vorbis/register_types.cpp b/modules/vorbis/register_types.cpp index 0ea1fbe8b2..8219e9e7ba 100644 --- a/modules/vorbis/register_types.cpp +++ b/modules/vorbis/register_types.cpp @@ -32,16 +32,17 @@ #include "audio_stream_ogg_vorbis.h" -static ResourceFormatLoaderAudioStreamOGGVorbis *vorbis_stream_loader = NULL; +static Ref<ResourceFormatLoaderAudioStreamOGGVorbis> vorbis_stream_loader; void register_vorbis_types() { - vorbis_stream_loader = memnew(ResourceFormatLoaderAudioStreamOGGVorbis); + vorbis_stream_loader.instance(); ResourceLoader::add_resource_format_loader(vorbis_stream_loader); ClassDB::register_class<AudioStreamOGGVorbis>(); } void unregister_vorbis_types() { - memdelete(vorbis_stream_loader); + ResourceLoader::remove_resource_format_loader(vorbis_stream_loader); + vorbis_stream_loader.unref(); } diff --git a/modules/webm/register_types.cpp b/modules/webm/register_types.cpp index 121b528d5b..dfa2dcf21c 100644 --- a/modules/webm/register_types.cpp +++ b/modules/webm/register_types.cpp @@ -32,11 +32,11 @@ #include "video_stream_webm.h" -static ResourceFormatLoaderWebm *resource_loader_webm = NULL; +static Ref<ResourceFormatLoaderWebm> resource_loader_webm; void register_webm_types() { - resource_loader_webm = memnew(ResourceFormatLoaderWebm); + resource_loader_webm.instance(); ResourceLoader::add_resource_format_loader(resource_loader_webm, true); ClassDB::register_class<VideoStreamWebm>(); @@ -44,7 +44,9 @@ void register_webm_types() { void unregister_webm_types() { - if (resource_loader_webm) { - memdelete(resource_loader_webm); + ResourceLoader::remove_resource_format_loader(resource_loader_webm); + + if (resource_loader_webm.is_valid()) { + resource_loader_webm.unref(); } } diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h index 3739a73114..9501f513a0 100644 --- a/modules/webm/video_stream_webm.h +++ b/modules/webm/video_stream_webm.h @@ -127,6 +127,7 @@ public: }; class ResourceFormatLoaderWebm : public ResourceFormatLoader { + GDCLASS(ResourceFormatLoaderWebm, 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; |