From 5c6353ae17e1da96b21465309df2810d817becb0 Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Thu, 5 Oct 2023 16:31:11 +0200 Subject: [PATCH] Fix extensions loading/initializing even when entry point fails --- core/extension/gdextension.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp index 7e280466a85..2592b18eac8 100644 --- a/core/extension/gdextension.cpp +++ b/core/extension/gdextension.cpp @@ -743,6 +743,7 @@ Error GDExtension::open_library(const String &p_path, const String &p_entry_symb return OK; } else { ERR_PRINT("GDExtension initialization function '" + p_entry_symbol + "' returned an error."); + OS::get_singleton()->close_dynamic_library(library); return FAILED; } } @@ -928,6 +929,10 @@ Error GDExtensionResourceLoader::load_gdextension_resource(const String &p_path, DirAccess::remove_absolute(p_extension->get_temp_library_path()); } #endif + + // Unreference the extension so that this loading can be considered a failure. + p_extension.unref(); + // Errors already logged in open_library() return err; }