summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2016-10-06 20:24:32 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2016-10-06 20:24:32 +0200
commitee7df2c89ab0608c84f8c9390e1ed888dc1f805d (patch)
treef7fdbc3c10bedfb5cb72ce639bc62fa3f4129a9f /modules
parent1f9e16119f2b17fa507bdee8529459ed91f27b8c (diff)
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
Diffstat (limited to 'modules')
-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 8f4f5ef4ca..c7678b94b2 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -3101,6 +3101,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