aboutsummaryrefslogtreecommitdiff
path: root/modules/gdscript/gd_parser.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli2016-10-06 20:24:32 +0200
committerRémi Verschelde2016-10-09 17:40:19 +0200
commite51cd3d454758b15126181013745e45488052ec3 (patch)
tree32508005490199307bd3e206c4c20284a3eae1dc /modules/gdscript/gd_parser.cpp
parenta7d6894a9ff44c77865e947058e8fd903041e065 (diff)
downloadgodot-e51cd3d454758b15126181013745e45488052ec3.tar.gz
godot-e51cd3d454758b15126181013745e45488052ec3.tar.zst
godot-e51cd3d454758b15126181013745e45488052ec3.zip
Throw an error when exporting a resource class
"export var tex = Texture" will now throw an error to avoid crashing the editor: "Exported constant not a type or resource" Fixes #6719 . Closes #6729 (cherry picked from commit ee7df2c89ab0608c84f8c9390e1ed888dc1f805d)
Diffstat (limited to 'modules/gdscript/gd_parser.cpp')
-rw-r--r--modules/gdscript/gd_parser.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index eb33f0e75..b005230d8 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -2938,6 +2938,16 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
member._export.type=cn->value.get_type();
member._export.usage|=PROPERTY_USAGE_SCRIPT_VARIABLE;
+ if (cn->value.get_type()==Variant::OBJECT) {
+ Object *obj = cn->value;
+ Resource *res = obj->cast_to<Resource>();
+ if(res==NULL) {
+ _set_error("Exported constant not a type or resource.");
+ return;
+ }
+ member._export.hint=PROPERTY_HINT_RESOURCE_TYPE;
+ member._export.hint_string=res->get_type();
+ }
}
}
#ifdef TOOLS_ENABLED