Merge pull request #83285 from dsnopek/gdextension-double-reload
GDExtension: Prevent issues with the editor trying to reload GDExtensions through its usual mechanism
This commit is contained in:
commit
eb9903b4ce
2 changed files with 15 additions and 5 deletions
|
@ -35,6 +35,7 @@
|
|||
#include "core/object/method_bind.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/version.h"
|
||||
#include "gdextension_manager.h"
|
||||
|
||||
extern void gdextension_setup_interface();
|
||||
extern GDExtensionInterfaceFunctionPtr gdextension_get_proc_address(const char *p_name);
|
||||
|
@ -949,11 +950,18 @@ Error GDExtensionResourceLoader::load_gdextension_resource(const String &p_path,
|
|||
}
|
||||
|
||||
Ref<Resource> GDExtensionResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
|
||||
Ref<GDExtension> lib;
|
||||
Error err = load_gdextension_resource(p_path, lib);
|
||||
if (err != OK && r_error) {
|
||||
// Errors already logged in load_gdextension_resource().
|
||||
*r_error = err;
|
||||
// We can't have two GDExtension resource object representing the same library, because
|
||||
// loading (or unloading) a GDExtension affects global data. So, we need reuse the same
|
||||
// object if one has already been loaded (even if caching is disabled at the resource
|
||||
// loader level).
|
||||
GDExtensionManager *manager = GDExtensionManager::get_singleton();
|
||||
Ref<GDExtension> 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;
|
||||
}
|
||||
}
|
||||
return lib;
|
||||
}
|
||||
|
|
|
@ -112,6 +112,8 @@ protected:
|
|||
public:
|
||||
HashMap<String, String> class_icon_paths;
|
||||
|
||||
virtual bool editor_can_reload_from_file() override { return false; } // Reloading is handled in a special way.
|
||||
|
||||
static String get_extension_list_config_file();
|
||||
static String find_extension_library(const String &p_path, Ref<ConfigFile> p_config, std::function<bool(String)> p_has_feature, PackedStringArray *r_tags = nullptr);
|
||||
|
||||
|
|
Loading…
Reference in a new issue