diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2021-01-06 20:25:05 +0100 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2021-01-06 23:40:50 +0100 |
commit | 6fbe0a494b9945f7adcc8603ebfbfeb040f718ba (patch) | |
tree | 1deb0db29e89cb1ca37e8834e5d089fe876390dc /editor/property_editor.cpp | |
parent | 8158d17edf18e3d6ec847d2cb710012361e7b12e (diff) |
Fix cases of resources destroyed too early
Diffstat (limited to 'editor/property_editor.cpp')
-rw-r--r-- | editor/property_editor.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 93689dd4cd..07312e42b4 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -262,7 +262,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { return; } - Object *obj = ClassDB::instance(intype); + Variant obj = ClassDB::instance(intype); if (!obj) { if (ScriptServer::is_global_class(intype)) { @@ -280,7 +280,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { res->call("set_instance_base_type", owner->get_class()); } - v = res; + v = obj; emit_signal("variant_changed"); } break; @@ -1064,7 +1064,7 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) { String intype = inheritors_array[p_idx]; - Object *obj = ClassDB::instance(intype); + Variant obj = ClassDB::instance(intype); if (!obj) { if (ScriptServer::is_global_class(intype)) { @@ -1075,11 +1075,9 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) { } ERR_FAIL_COND(!obj); + ERR_FAIL_COND(!Object::cast_to<Resource>(obj)); - Resource *res = Object::cast_to<Resource>(obj); - ERR_FAIL_COND(!res); - - v = res; + v = obj; emit_signal("variant_changed"); hide(); } @@ -1251,7 +1249,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { String intype = inheritors_array[0]; if (hint == PROPERTY_HINT_RESOURCE_TYPE) { - Object *obj = ClassDB::instance(intype); + Variant obj = ClassDB::instance(intype); if (!obj) { if (ScriptServer::is_global_class(intype)) { @@ -1262,10 +1260,9 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } ERR_BREAK(!obj); - Resource *res = Object::cast_to<Resource>(obj); - ERR_BREAK(!res); + ERR_BREAK(!Object::cast_to<Resource>(obj)); - v = res; + v = obj; emit_signal("variant_changed"); hide(); } |