From e5f1d19352dbaafab96538b91fad0ce11cf0d046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 10 Jan 2019 12:45:57 +0100 Subject: Consistency in resource format saver/loader de-registration Some used 'is_valid()' checks, others not. Validity is already checked in 'unref()', and 'remove_resource_format_*()' has an ERR_FAIL condition on 'is_null()' already (which shouldn't happen since we're only unregistering things that we previously registered. Also add missing GDCLASS statement in ResourceFormatLoaderVideoStreamGDNative, missed in #20552 which was last amended before #19501 was merged. --- core/register_core_types.cpp | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'core') diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 68e293ba13..666384b093 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -68,8 +68,8 @@ static Ref resource_saver_binary; static Ref resource_loader_binary; static Ref resource_format_importer; - static Ref resource_format_image; +static Ref resource_format_po; static _ResourceLoader *_resource_loader = NULL; static _ResourceSaver *_resource_saver = NULL; @@ -77,7 +77,6 @@ static _OS *_os = NULL; static _Engine *_engine = NULL; static _ClassDB *_classdb = NULL; static _Marshalls *_marshalls = NULL; -static Ref resource_format_po; static _JSON *_json = NULL; static IP *ip = NULL; @@ -251,25 +250,17 @@ void unregister_core_types() { memdelete(_geometry); - if (resource_format_image.is_valid()) { - ResourceLoader::remove_resource_format_loader(resource_format_image); - resource_format_image.unref(); - } - - if (resource_saver_binary.is_valid()) { - ResourceSaver::remove_resource_format_saver(resource_saver_binary); - resource_saver_binary.unref(); - } - - if (resource_loader_binary.is_valid()) { - ResourceLoader::remove_resource_format_loader(resource_loader_binary); - resource_loader_binary.unref(); - } - - if (resource_format_importer.is_valid()) { - ResourceLoader::remove_resource_format_loader(resource_format_importer); - resource_format_importer.unref(); - } + ResourceLoader::remove_resource_format_loader(resource_format_image); + resource_format_image.unref(); + + ResourceSaver::remove_resource_format_saver(resource_saver_binary); + resource_saver_binary.unref(); + + ResourceLoader::remove_resource_format_loader(resource_loader_binary); + resource_loader_binary.unref(); + + ResourceLoader::remove_resource_format_loader(resource_format_importer); + resource_format_importer.unref(); ResourceLoader::remove_resource_format_loader(resource_format_po); resource_format_po.unref(); -- cgit v1.2.3