Fix gdscript analyzer error when instantiating EditorPlugins.
Editor code is not instantiable outside of the editor
(1d14c054a1/core/object/class_db.cpp (L369)).
This is fine for editor plugins and the like, but the GDScript analyzer
balks at it, causing F5 runs to fail: #73525.
Instead, we really just want to know if the type is abstract - so add
a new ClassDB method to check that and nothing else.
Update core/object/class_db.cpp
Apply code review comments
Co-Authored-By: Bryce <1522777+baptr@users.noreply.github.com>
This commit is contained in:
@@ -671,6 +671,21 @@ bool ClassDB::can_instantiate(const StringName &p_class) {
|
||||
return (!ti->disabled && ti->creation_func != nullptr && !(ti->gdextension && !ti->gdextension->create_instance));
|
||||
}
|
||||
|
||||
bool ClassDB::is_abstract(const StringName &p_class) {
|
||||
OBJTYPE_RLOCK;
|
||||
|
||||
ClassInfo *ti = classes.getptr(p_class);
|
||||
if (!ti) {
|
||||
if (!ScriptServer::is_global_class(p_class)) {
|
||||
ERR_FAIL_V_MSG(false, "Cannot get class '" + String(p_class) + "'.");
|
||||
}
|
||||
String path = ScriptServer::get_global_class_path(p_class);
|
||||
Ref<Script> scr = ResourceLoader::load(path);
|
||||
return scr.is_valid() && scr->is_valid() && scr->is_abstract();
|
||||
}
|
||||
return ti->creation_func == nullptr && (!ti->gdextension || ti->gdextension->create_instance == nullptr);
|
||||
}
|
||||
|
||||
bool ClassDB::is_virtual(const StringName &p_class) {
|
||||
OBJTYPE_RLOCK;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user