summaryrefslogtreecommitdiffstats
path: root/core/extension
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2023-08-16 17:49:59 -0500
committerDavid Snopek <dsnopek@gmail.com>2023-08-17 13:23:31 -0500
commit908b8c050779a8838eaae4a671653f3961b8051f (patch)
tree5d7df7c0c7c435406f101785b8ac3457c575a149 /core/extension
parenta278c1b98a81738a35b96a933a6e6cf771f9ab2d (diff)
downloadredot-engine-908b8c050779a8838eaae4a671653f3961b8051f.tar.gz
GDExtension: Remove DLL copy if it fails to load
Diffstat (limited to 'core/extension')
-rw-r--r--core/extension/gdextension.cpp6
-rw-r--r--core/extension/gdextension.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp
index 1e4cd81034..e39a531d0d 100644
--- a/core/extension/gdextension.cpp
+++ b/core/extension/gdextension.cpp
@@ -689,6 +689,12 @@ Ref<Resource> GDExtensionResourceLoader::load(const String &p_path, const String
}
if (err != OK) {
+#if defined(WINDOWS_ENABLED) && defined(TOOLS_ENABLED)
+ // If the DLL fails to load, make sure that temporary DLL copies are cleaned up.
+ if (Engine::get_singleton()->is_editor_hint()) {
+ DirAccess::remove_absolute(lib->get_temp_library_path());
+ }
+#endif
// Errors already logged in open_library()
return Ref<Resource>();
}
diff --git a/core/extension/gdextension.h b/core/extension/gdextension.h
index 5a4dd3d5f5..5a0e39302b 100644
--- a/core/extension/gdextension.h
+++ b/core/extension/gdextension.h
@@ -81,6 +81,7 @@ public:
#if defined(WINDOWS_ENABLED) && defined(TOOLS_ENABLED)
void set_temp_library_path(const String &p_path) { temp_lib_path = p_path; }
+ String get_temp_library_path() const { return temp_lib_path; }
#endif
enum InitializationLevel {