summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2023-11-08 09:02:20 -0600
committerDavid Snopek <dsnopek@gmail.com>2023-11-09 11:24:57 -0600
commit09fcc3a1adf2d3a54fdcc99af0144db19266d306 (patch)
tree5a6da7f0e2697f2d13410e67e17d8a1391bc1bc5 /core
parent3e7f638d7b574785f521beafaf52a6ad95be016f (diff)
downloadredot-engine-09fcc3a1adf2d3a54fdcc99af0144db19266d306.tar.gz
Change `GDExtension`'s `library_path` back to an absolute path
Diffstat (limited to 'core')
-rw-r--r--core/extension/gdextension.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp
index 6c3d0a6148..4f9bb8c127 100644
--- a/core/extension/gdextension.cpp
+++ b/core/extension/gdextension.cpp
@@ -678,12 +678,11 @@ GDExtensionInterfaceFunctionPtr GDExtension::get_interface_function(StringName p
}
Error GDExtension::open_library(const String &p_path, const String &p_entry_symbol) {
- library_path = p_path;
-
String abs_path = ProjectSettings::get_singleton()->globalize_path(p_path);
#if defined(WINDOWS_ENABLED) && defined(TOOLS_ENABLED)
// If running on the editor on Windows, we copy the library and open the copy.
// This is so the original file isn't locked and can be updated by a compiler.
+ bool library_copied = false;
if (Engine::get_singleton()->is_editor_hint()) {
if (!FileAccess::exists(abs_path)) {
ERR_PRINT("GDExtension library not found: " + library_path);
@@ -705,6 +704,7 @@ Error GDExtension::open_library(const String &p_path, const String &p_entry_symb
return ERR_CANT_CREATE;
}
FileAccess::set_hidden_attribute(copy_path, true);
+ library_copied = true;
// Save the copied path so it can be deleted later.
temp_lib_path = copy_path;
@@ -714,12 +714,20 @@ Error GDExtension::open_library(const String &p_path, const String &p_entry_symb
}
#endif
- Error err = OS::get_singleton()->open_dynamic_library(abs_path, library, true);
+ Error err = OS::get_singleton()->open_dynamic_library(abs_path, library, true, &library_path);
if (err != OK) {
ERR_PRINT("GDExtension dynamic library not found: " + abs_path);
return err;
}
+#if defined(WINDOWS_ENABLED) && defined(TOOLS_ENABLED)
+ // If we copied the file, let's change the library path to point at the original,
+ // because that's what we want to check to see if it's changed.
+ if (library_copied) {
+ library_path = library_path.get_base_dir() + "\\" + p_path.get_file();
+ }
+#endif
+
void *entry_funcptr = nullptr;
err = OS::get_singleton()->get_dynamic_library_symbol_handle(library, p_entry_symbol, entry_funcptr, false);