Skip to content

Commit 908b8c0

Browse files
committed
GDExtension: Remove DLL copy if it fails to load
1 parent a278c1b commit 908b8c0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

core/extension/gdextension.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,12 @@ Ref<Resource> GDExtensionResourceLoader::load(const String &p_path, const String
689689
}
690690

691691
if (err != OK) {
692+
#if defined(WINDOWS_ENABLED) && defined(TOOLS_ENABLED)
693+
// If the DLL fails to load, make sure that temporary DLL copies are cleaned up.
694+
if (Engine::get_singleton()->is_editor_hint()) {
695+
DirAccess::remove_absolute(lib->get_temp_library_path());
696+
}
697+
#endif
692698
// Errors already logged in open_library()
693699
return Ref<Resource>();
694700
}

core/extension/gdextension.h

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class GDExtension : public Resource {
8181

8282
#if defined(WINDOWS_ENABLED) && defined(TOOLS_ENABLED)
8383
void set_temp_library_path(const String &p_path) { temp_lib_path = p_path; }
84+
String get_temp_library_path() const { return temp_lib_path; }
8485
#endif
8586

8687
enum InitializationLevel {

0 commit comments

Comments
 (0)