Merge pull request #30543 from kawa-yoiko/editor-script-typecheck
Fix potential crash caused by type mismatch in Ref
This commit is contained in:
commit
0471e4d578
1 changed files with 6 additions and 4 deletions
|
@ -70,7 +70,8 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
|
||||||
}
|
}
|
||||||
} else if (p_id == BUTTON_SCRIPT) {
|
} else if (p_id == BUTTON_SCRIPT) {
|
||||||
RefPtr script = n->get_script();
|
RefPtr script = n->get_script();
|
||||||
if (!script.is_null())
|
Ref<Script> script_typed = script;
|
||||||
|
if (!script_typed.is_null())
|
||||||
emit_signal("open_script", script);
|
emit_signal("open_script", script);
|
||||||
|
|
||||||
} else if (p_id == BUTTON_VISIBILITY) {
|
} else if (p_id == BUTTON_VISIBILITY) {
|
||||||
|
@ -210,7 +211,8 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
|
||||||
if (connect_to_script_mode) {
|
if (connect_to_script_mode) {
|
||||||
Color accent = get_color("accent_color", "Editor");
|
Color accent = get_color("accent_color", "Editor");
|
||||||
|
|
||||||
if (!p_node->get_script().is_null()) {
|
Ref<Script> script = p_node->get_script();
|
||||||
|
if (!script.is_null()) {
|
||||||
//has script
|
//has script
|
||||||
item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT);
|
item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT);
|
||||||
} else {
|
} else {
|
||||||
|
@ -290,8 +292,8 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
|
||||||
if (!p_node->is_connected("script_changed", this, "_node_script_changed"))
|
if (!p_node->is_connected("script_changed", this, "_node_script_changed"))
|
||||||
p_node->connect("script_changed", this, "_node_script_changed", varray(p_node));
|
p_node->connect("script_changed", this, "_node_script_changed", varray(p_node));
|
||||||
|
|
||||||
if (!p_node->get_script().is_null()) {
|
Ref<Script> script = p_node->get_script();
|
||||||
Ref<Script> script = p_node->get_script();
|
if (!script.is_null()) {
|
||||||
item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path());
|
item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue