From 2997a3aa2363c3e2c56469790b9ac20701d528df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Wed, 6 Jan 2021 20:25:05 +0100 Subject: [PATCH] Fix cases of resources destroyed too early --- editor/create_dialog.cpp | 6 +++--- editor/create_dialog.h | 2 +- editor/editor_data.cpp | 23 ++++++++++++----------- editor/editor_data.h | 4 ++-- editor/editor_properties.cpp | 15 ++++++--------- editor/filesystem_dock.cpp | 9 +++------ editor/inspector_dock.cpp | 5 ++--- editor/property_editor.cpp | 19 ++++++++----------- editor/scene_tree_dock.cpp | 4 ++-- 9 files changed, 39 insertions(+), 48 deletions(-) diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 63d391147ca..4acf6e4e707 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -515,7 +515,7 @@ String CreateDialog::get_selected_type() { return String(); } -Object *CreateDialog::instance_selected() { +Variant CreateDialog::instance_selected() { TreeItem *selected = search_options->get_selected(); @@ -529,7 +529,7 @@ Object *CreateDialog::instance_selected() { if (custom != String()) { if (ScriptServer::is_global_class(custom)) { - Object *obj = EditorNode::get_editor_data().script_class_instance(custom); + Variant obj = EditorNode::get_editor_data().script_class_instance(custom); Node *n = Object::cast_to(obj); if (n) n->set_name(custom); @@ -541,7 +541,7 @@ Object *CreateDialog::instance_selected() { } } - return NULL; + return Variant(); } void CreateDialog::_item_selected() { diff --git a/editor/create_dialog.h b/editor/create_dialog.h index 94ff1b5bb26..c697b740f75 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -97,7 +97,7 @@ protected: void _save_and_update_favorite_list(); public: - Object *instance_selected(); + Variant instance_selected(); String get_selected_type(); void set_base_type(const String &p_base); diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 0f6e3485dae..67b0f5b16b9 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -497,7 +497,7 @@ void EditorData::add_custom_type(const String &p_type, const String &p_inherits, custom_types[p_inherits].push_back(ct); } -Object *EditorData::instance_custom_type(const String &p_type, const String &p_inherits) { +Variant EditorData::instance_custom_type(const String &p_type, const String &p_inherits) { if (get_custom_types().has(p_inherits)) { @@ -505,18 +505,19 @@ Object *EditorData::instance_custom_type(const String &p_type, const String &p_i if (get_custom_types()[p_inherits][i].name == p_type) { Ref