Merge pull request #97532 from kisg/use_loader_library_check

GDExtension: Use loader to check if the library exists.
This commit is contained in:
Rémi Verschelde 2024-10-01 17:31:14 +02:00
commit 3b17e3470a
No known key found for this signature in database
GPG key ID: C3336907360768E1
4 changed files with 8 additions and 1 deletions

View file

@ -259,6 +259,10 @@ bool GDExtensionLibraryLoader::has_library_changed() const {
return false;
}
bool GDExtensionLibraryLoader::library_exists() const {
return FileAccess::exists(resource_path);
}
Error GDExtensionLibraryLoader::parse_gdextension_file(const String &p_path) {
resource_path = p_path;

View file

@ -77,6 +77,7 @@ public:
virtual void close_library() override;
virtual bool is_library_open() const override;
virtual bool has_library_changed() const override;
virtual bool library_exists() const override;
Error parse_gdextension_file(const String &p_path);
};

View file

@ -42,6 +42,7 @@ public:
virtual void close_library() = 0;
virtual bool is_library_open() const = 0;
virtual bool has_library_changed() const = 0;
virtual bool library_exists() const = 0;
};
#endif // GDEXTENSION_LOADER_H

View file

@ -302,7 +302,8 @@ bool GDExtensionManager::ensure_extensions_loaded(const HashSet<String> &p_exten
for (const String &loaded_extension : loaded_extensions) {
if (!p_extensions.has(loaded_extension)) {
// The extension may not have a .gdextension file.
if (!FileAccess::exists(loaded_extension)) {
const Ref<GDExtension> extension = GDExtensionManager::get_singleton()->get_extension(loaded_extension);
if (!extension->get_loader()->library_exists()) {
extensions_removed.push_back(loaded_extension);
}
}