diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-09-26 08:31:26 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-09-26 08:31:26 +0200 |
commit | 0c626bdfb0a752f1bf8c44ab782759905462d010 (patch) | |
tree | e6af9ad2eaa6bd8b9d7fd3fa5b72731357e9008f /modules/gdscript/gdscript_compiler.cpp | |
parent | 563d22565462f35f3f592c0cdd1abd275ebe28ec (diff) | |
parent | 16b024ba8266485015efe8d6350b4f299f91b53d (diff) | |
download | redot-engine-0c626bdfb0a752f1bf8c44ab782759905462d010.tar.gz |
Merge pull request #82294 from dalexeev/gds-fix-gdsnc-crash
GDScript: Fix crash with `GDScriptNativeClass`
Diffstat (limited to 'modules/gdscript/gdscript_compiler.cpp')
-rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 7f2c401afc..9a9e96b8e8 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -104,13 +104,24 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D if (p_handle_metatype && p_datatype.is_meta_type) { result.kind = GDScriptDataType::NATIVE; result.builtin_type = Variant::OBJECT; - result.native_type = GDScriptNativeClass::get_class_static(); + // Fixes GH-82255. `GDScriptNativeClass` is obtainable in GDScript, + // but is not a registered and exposed class, so `GDScriptNativeClass` + // is missing from `GDScriptLanguage::get_singleton()->get_global_map()`. + //result.native_type = GDScriptNativeClass::get_class_static(); + result.native_type = Object::get_class_static(); break; } result.kind = GDScriptDataType::NATIVE; - result.native_type = p_datatype.native_type; result.builtin_type = p_datatype.builtin_type; + result.native_type = p_datatype.native_type; + +#ifdef DEBUG_ENABLED + if (unlikely(!GDScriptLanguage::get_singleton()->get_global_map().has(result.native_type))) { + ERR_PRINT(vformat(R"(GDScript bug: Native class "%s" not found.)", result.native_type)); + result.native_type = Object::get_class_static(); + } +#endif } break; case GDScriptParser::DataType::SCRIPT: { if (p_handle_metatype && p_datatype.is_meta_type) { |