Skip to content

Commit 3b17e34

Browse files
committed
Merge pull request godotengine#97532 from kisg/use_loader_library_check
GDExtension: Use loader to check if the library exists.
2 parents 8aabdc4 + 8a41b1d commit 3b17e34

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

core/extension/gdextension_library_loader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ bool GDExtensionLibraryLoader::has_library_changed() const {
259259
return false;
260260
}
261261

262+
bool GDExtensionLibraryLoader::library_exists() const {
263+
return FileAccess::exists(resource_path);
264+
}
265+
262266
Error GDExtensionLibraryLoader::parse_gdextension_file(const String &p_path) {
263267
resource_path = p_path;
264268

core/extension/gdextension_library_loader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class GDExtensionLibraryLoader : public GDExtensionLoader {
7777
virtual void close_library() override;
7878
virtual bool is_library_open() const override;
7979
virtual bool has_library_changed() const override;
80+
virtual bool library_exists() const override;
8081

8182
Error parse_gdextension_file(const String &p_path);
8283
};

core/extension/gdextension_loader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class GDExtensionLoader : public RefCounted {
4242
virtual void close_library() = 0;
4343
virtual bool is_library_open() const = 0;
4444
virtual bool has_library_changed() const = 0;
45+
virtual bool library_exists() const = 0;
4546
};
4647

4748
#endif // GDEXTENSION_LOADER_H

core/extension/gdextension_manager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ bool GDExtensionManager::ensure_extensions_loaded(const HashSet<String> &p_exten
302302
for (const String &loaded_extension : loaded_extensions) {
303303
if (!p_extensions.has(loaded_extension)) {
304304
// The extension may not have a .gdextension file.
305-
if (!FileAccess::exists(loaded_extension)) {
305+
const Ref<GDExtension> extension = GDExtensionManager::get_singleton()->get_extension(loaded_extension);
306+
if (!extension->get_loader()->library_exists()) {
306307
extensions_removed.push_back(loaded_extension);
307308
}
308309
}

0 commit comments

Comments
 (0)