summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-03-16 11:09:40 -0700
committerGitHub <noreply@github.com>2019-03-16 11:09:40 -0700
commitc1fae20400df7be9c8fd31b10b0f7a7f8c0001f3 (patch)
tree8e55087e57de4b08b28c304a4d4f0b652a06eac0
parent67764bff6455258ed669542bf2cb048315851730 (diff)
parentd3042d162d49a45fa288f60b6068d5e7ae4aa54f (diff)
Merge pull request #26706 from YeldhamDev/multinode_scriptclear_fix
Fix clearing scripts while multiple nodes are selected
-rw-r--r--editor/scene_tree_dock.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 66163d7e0a..19b46ef90f 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -377,7 +377,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_CLEAR_SCRIPT: {
- List<Node *> selection = editor_selection->get_selected_node_list();
+ Array selection = editor_selection->get_selected_nodes();
if (selection.empty())
return;
@@ -385,13 +385,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().create_action(TTR("Clear Script"));
editor_data->get_undo_redo().add_do_method(editor, "push_item", (Script *)NULL);
- for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
+ for (int i = 0; i < selection.size(); i++) {
- Ref<Script> existing = E->get()->get_script();
+ Node *n = Object::cast_to<Node>(selection[i]);
+ Ref<Script> existing = n->get_script();
if (existing.is_valid()) {
const RefPtr empty;
- editor_data->get_undo_redo().add_do_method(E->get(), "set_script", empty);
- editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing);
+ editor_data->get_undo_redo().add_do_method(n, "set_script", empty);
+ editor_data->get_undo_redo().add_undo_method(n, "set_script", existing);
}
}
@@ -1653,9 +1654,9 @@ void SceneTreeDock::_update_script_button() {
}
} else {
button_create_script->show();
- List<Node *> selection = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
- for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Node *n = E->get();
+ Array selection = editor_selection->get_selected_nodes();
+ for (int i = 0; i < selection.size(); i++) {
+ Node *n = Object::cast_to<Node>(selection[i]);
if (!n->get_script().is_null()) {
button_clear_script->show();
return;