summaryrefslogtreecommitdiff
path: root/editor/editor_properties.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2020-12-29 13:14:39 +0100
committerPedro J. Estébanez <pedrojrulez@gmail.com>2020-12-29 13:14:39 +0100
commitd2d29c42f280d38511aed673ef9c90ad5492bb30 (patch)
tree2d346c5a13c8da7a1a39c5f62fc2e9ee91ce973f /editor/editor_properties.cpp
parente11be748566b96e8a5ef490a1db9106bcd6d47bc (diff)
Fix instantiation of resource as property value
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r--editor/editor_properties.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 972fd0723a..9c27b50a9a 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -2546,10 +2546,12 @@ void EditorPropertyResource::_menu_option(int p_which) {
}
Object *obj = nullptr;
+ RES res_temp;
if (ScriptServer::is_global_class(intype)) {
obj = ClassDB::instance(ScriptServer::get_global_class_native_base(intype));
if (obj) {
+ res_temp = obj;
Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(intype));
if (script.is_valid()) {
obj->set_script(Variant(script));
@@ -2557,21 +2559,21 @@ void EditorPropertyResource::_menu_option(int p_which) {
}
} else {
obj = ClassDB::instance(intype);
+ res_temp = obj;
}
if (!obj) {
obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource");
+ res_temp = obj;
}
- ERR_BREAK(!obj);
- Resource *resp = Object::cast_to<Resource>(obj);
- ERR_BREAK(!resp);
+ ERR_BREAK(!res_temp.is_valid());
if (get_edited_object() && base_type != String() && base_type == "Script") {
//make visual script the right type
- resp->call("set_instance_base_type", get_edited_object()->get_class());
+ res_temp->call("set_instance_base_type", get_edited_object()->get_class());
}
- res = Ref<Resource>(resp);
+ res = res_temp;
emit_changed(get_edited_property(), res);
update_property();