Repository: godotengine/godot
File: editor/scene/canvas_item_editor_plugin.cpp (C++)

Code before:
}

void CanvasItemEditor::_reset_transform(TransformType p_type) {
	List<Node *> selection = editor_selection->get_full_selected_node_list();
	if (selection.is_empty()) {
		return;
	}
	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Reset Transform"));
	for (Node *node : selection) {
		Node2D *res_node = Object::cast_to<Node2D>(node);
		if (res_node) {
			switch (p_type) {
				case TransformType::POSITION:
					undo_redo->add_undo_method(res_node, "set_position", res_node->get_position());
					undo_redo->add_do_method(res_node, "set_position", Vector2());
					break;
				case TransformType::ROTATION:
					undo_redo->add_undo_method(res_node, "set_rotation", res_node->get_rotation());
					undo_redo->add_do_method(res_node, "set_rotation", 0);
					break;
				case TransformType::SCALE:
					undo_redo->add_undo_method(res_node, "set_scale", res_node->get_scale());
					undo_redo->add_do_method(res_node, "set_scale", Size2(1, 1));
					break;
			}
		}
		Control *res_control = Object::cast_to<Control>(node);
		if (res_control) {
			switch (p_type) {
				case TransformType::POSITION:
					undo_redo->add_undo_method(res_control, "set_position", res_control->get_position());
					undo_redo->add_do_method(res_control, "set_position", Vector2());
					break;
				case TransformType::ROTATION:
					undo_redo->add_undo_method(res_control, "set_rotation", res_control->get_rotation());
					undo_redo->add_do_method(res_control, "set_rotation", 0);
					break;
				case TransformType::SCALE:
					undo_redo->add_undo_method(res_control, "set_scale", res_control->get_scale());
					undo_redo->add_do_method(res_control, "set_scale", Size2(1, 1));
					break;
			}
		}
	}
	undo_redo->commit_action();
}

void CanvasItemEditor::_switch_theme_preview(int p_mode) {
	view_menu->get_popup()->hide();


Review comment (suggestion):
You could add a continue here. If it's Node2D, it won't be a Control.

```suggestion
			}
			continue;
```

Code after:
}

void CanvasItemEditor::_reset_transform(TransformType p_type) {
	List<Node *> selection = editor_selection->get_full_selected_node_list();
	if (selection.is_empty()) {
		return;
	}
	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Reset Transform"));
	for (Node *node : selection) {
		Node2D *res_node = Object::cast_to<Node2D>(node);
		if (res_node) {
			switch (p_type) {
				case TransformType::POSITION:
					undo_redo->add_undo_method(res_node, "set_position", res_node->get_position());
					undo_redo->add_do_method(res_node, "set_position", Vector2());
					break;
				case TransformType::ROTATION:
					undo_redo->add_undo_method(res_node, "set_rotation", res_node->get_rotation());
					undo_redo->add_do_method(res_node, "set_rotation", 0);
					break;
				case TransformType::SCALE:
					undo_redo->add_undo_method(res_node, "set_scale", res_node->get_scale());
					undo_redo->add_do_method(res_node, "set_scale", Size2(1, 1));
					break;
			}
			continue;
		}
		Control *res_control = Object::cast_to<Control>(node);
		if (res_control) {
			switch (p_type) {
				case TransformType::POSITION:
					undo_redo->add_undo_method(res_control, "set_position", res_control->get_position());
					undo_redo->add_do_method(res_control, "set_position", Vector2());
					break;
				case TransformType::ROTATION:
					undo_redo->add_undo_method(res_control, "set_rotation", res_control->get_rotation());
					undo_redo->add_do_method(res_control, "set_rotation", 0);
					break;
				case TransformType::SCALE:
					undo_redo->add_undo_method(res_control, "set_scale", res_control->get_scale());
					undo_redo->add_do_method(res_control, "set_scale", Size2(1, 1));
					break;
			}
		}
	}
	undo_redo->commit_action();
}

void CanvasItemEditor::_switch_theme_preview(int p_mode) {
	view_menu->get_popup()->hide();