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

Code before:
				Node *n2d_parent = n2d->get_parent();
				if (!n2d_parent) {
					continue;
				}

				undo_redo->add_do_method(n2d_parent, "add_child", new_bone);
				undo_redo->add_do_method(n2d_parent, "remove_child", n2d);
				undo_redo->add_do_method(new_bone, "add_child", n2d);
				undo_redo->add_do_method(n2d, "set_transform", Transform2D());
				undo_redo->add_do_method(this, "_set_owner_for_node_and_children", new_bone, editor_root);
				undo_redo->add_do_reference(new_bone);

				undo_redo->add_undo_method(new_bone, "remove_child", n2d);
				undo_redo->add_undo_method(n2d_parent, "add_child", n2d);
				undo_redo->add_undo_method(n2d_parent, "remove_child", new_bone);
				undo_redo->add_undo_method(n2d, "set_transform", new_bone->get_transform());
				undo_redo->add_undo_method(this, "_set_owner_for_node_and_children", n2d, editor_root);
			}
			undo_redo->commit_action();

		} break;
		case AUTO_RESAMPLE_CANVAS_ITEMS: {
			resample = !resample;
			int idx = view_menu->get_popup()->get_item_index(AUTO_RESAMPLE_CANVAS_ITEMS);
			view_menu->get_popup()->set_item_checked(idx, resample);
			resample_timer->stop();
			_update_oversampling();
			EditorSettings::get_singleton()->set_project_metadata("2d_editor", "resample", resample);
		} break;
	}
}

void CanvasItemEditor::_set_owner_for_node_and_children(Node *p_node, Node *p_owner) {
	p_node->set_owner(p_owner);
	for (int i = 0; i < p_node->get_child_count(); i++) {
		_set_owner_for_node_and_children(p_node->get_child(i), p_owner);
	}
}

void CanvasItemEditor::_focus_selection(int p_op) {
	Rect2 rect;
	int count = 0;

	const HashMap<ObjectID, Object *> &selection = editor_selection->get_selection();
	for (const KeyValue<ObjectID, Object *> &E : selection) {
		CanvasItem *ci = ObjectDB::get_instance<CanvasItem>(E.key);
		if (!ci) {
			continue;
		}
		const Transform2D canvas_item_transform = ci->get_global_transform();
		if (!canvas_item_transform.is_finite()) {

Review comment (suggestion):
```suggestion
			if (!resample_timer->is_stopped()) {
				resample_timer->stop();
			}
```

Code after:

				Node *n2d_parent = n2d->get_parent();
				if (!n2d_parent) {
					continue;
				}

				undo_redo->add_do_method(n2d_parent, "add_child", new_bone);
				undo_redo->add_do_method(n2d_parent, "remove_child", n2d);
				undo_redo->add_do_method(new_bone, "add_child", n2d);
				undo_redo->add_do_method(n2d, "set_transform", Transform2D());
				undo_redo->add_do_method(this, "_set_owner_for_node_and_children", new_bone, editor_root);
				undo_redo->add_do_reference(new_bone);

				undo_redo->add_undo_method(new_bone, "remove_child", n2d);
				undo_redo->add_undo_method(n2d_parent, "add_child", n2d);
				undo_redo->add_undo_method(n2d_parent, "remove_child", new_bone);
				undo_redo->add_undo_method(n2d, "set_transform", new_bone->get_transform());
				undo_redo->add_undo_method(this, "_set_owner_for_node_and_children", n2d, editor_root);
			}
			undo_redo->commit_action();

		} break;
		case AUTO_RESAMPLE_CANVAS_ITEMS: {
			auto_resampling_enabled = !auto_resampling_enabled;
			int idx = view_menu->get_popup()->get_item_index(AUTO_RESAMPLE_CANVAS_ITEMS);
			view_menu->get_popup()->set_item_checked(idx, auto_resampling_enabled);
			if (!resample_timer->is_stopped()) {
				resample_timer->stop();
			}
			_update_oversampling();
			EditorSettings::get_singleton()->set_project_metadata("2d_editor", "auto_resampling_enabled", auto_resampling_enabled);
		} break;
	}
}

void CanvasItemEditor::_set_owner_for_node_and_children(Node *p_node, Node *p_owner) {
	p_node->set_owner(p_owner);
	for (int i = 0; i < p_node->get_child_count(); i++) {
		_set_owner_for_node_and_children(p_node->get_child(i), p_owner);
	}
}

void CanvasItemEditor::_focus_selection(int p_op) {
	Rect2 rect;
	int count = 0;

	const HashMap<ObjectID, Object *> &selection = editor_selection->get_selection();
	for (const KeyValue<ObjectID, Object *> &E : selection) {
		CanvasItem *ci = ObjectDB::get_instance<CanvasItem>(E.key);
		if (!ci) {
			continue;