From f2bcd7d61f31d0a1204c3724660dc501e4b2b67f Mon Sep 17 00:00:00 2001 From: Mario Liebisch Date: Sat, 21 Oct 2023 17:00:18 +0200 Subject: [PATCH] GDExtension: Fixed error on loading extensions Previously, before loading an extension, the editor just tried to retrieve the extension by path to test if it's been loaded already. While this is handled gracefully, it ignored an error thrown inside `GDExtensionManager::get_extension()`, that would essentially still report a not yet loaded extension to the engine's log: ``` ERROR: Condition "!E" is true. Returning: Ref() at: GDExtensionManager::get_extension (core\extension\gdextension_manager.cpp:165) ``` This change actively checks whether the extension path is known and only then proceeds to actually return the already loaded extension or loads and returns the new one otherwise. --- core/extension/gdextension.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp index 26512d0c56..136a5bfbb2 100644 --- a/core/extension/gdextension.cpp +++ b/core/extension/gdextension.cpp @@ -959,13 +959,15 @@ Ref GDExtensionResourceLoader::load(const String &p_path, const String // object if one has already been loaded (even if caching is disabled at the resource // loader level). GDExtensionManager *manager = GDExtensionManager::get_singleton(); - Ref lib = manager->get_extension(p_path); - if (lib.is_null()) { - Error err = load_gdextension_resource(p_path, lib); - if (err != OK && r_error) { - // Errors already logged in load_gdextension_resource(). - *r_error = err; - } + if (manager->is_extension_loaded(p_path)) { + return manager->get_extension(p_path); + } + + Ref lib; + Error err = load_gdextension_resource(p_path, lib); + if (err != OK && r_error) { + // Errors already logged in load_gdextension_resource(). + *r_error = err; } return lib; }