Repository: godotengine/godot
File: editor/plugins/path_2d_editor_plugin.cpp (C++)

Code before:

	mode = MODE_EDIT;
	action = ACTION_NONE;

	curve_edit = memnew(Button);
	curve_edit->set_theme_type_variation("FlatButton");
	curve_edit->set_toggle_mode(true);
	curve_edit->set_pressed(true);
	curve_edit->set_focus_mode(Control::FOCUS_NONE);
	curve_edit->set_tooltip_text(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL) + TTR("Click: Add Point") + "\n" + TTR("Left Click: Split Segment (in curve)") + "\n" + TTR("Right Click: Delete Point"));
	curve_edit->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected).bind(MODE_EDIT));
	add_child(curve_edit);

	curve_edit_curve = memnew(Button);
	curve_edit_curve->set_theme_type_variation("FlatButton");
	curve_edit_curve->set_toggle_mode(true);
	curve_edit_curve->set_focus_mode(Control::FOCUS_NONE);
	curve_edit_curve->set_tooltip_text(TTR("Select Control Points (Shift+Drag)"));
	curve_edit_curve->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected).bind(MODE_EDIT_CURVE));
	add_child(curve_edit_curve);

	curve_create = memnew(Button);
	curve_create->set_theme_type_variation("FlatButton");
	curve_create->set_toggle_mode(true);
	curve_create->set_focus_mode(Control::FOCUS_NONE);
	curve_create->set_tooltip_text(TTR("Add Point (in empty space)"));
	curve_create->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected).bind(MODE_CREATE));
	add_child(curve_create);

	curve_del = memnew(Button);
	curve_del->set_theme_type_variation("FlatButton");
	curve_del->set_toggle_mode(true);
	curve_del->set_focus_mode(Control::FOCUS_NONE);
	curve_del->set_tooltip_text(TTR("Delete Point"));
	curve_del->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected).bind(MODE_DELETE));
	add_child(curve_del);

	curve_close = memnew(Button);
	curve_close->set_theme_type_variation("FlatButton");
	curve_close->set_focus_mode(Control::FOCUS_NONE);
	curve_close->set_tooltip_text(TTR("Close Curve"));
	curve_close->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected).bind(ACTION_CLOSE));
	add_child(curve_close);

	PopupMenu *menu;

	handle_menu = memnew(MenuButton);
	handle_menu->set_flat(false);
	handle_menu->set_theme_type_variation("FlatMenuButton");
	handle_menu->set_text(TTR("Options"));
	add_child(handle_menu);

Review comment (suggestion):
```suggestion
	if (!node || node->get_curve().is_null()) {
```

Code after:
			bool is_checked = pm->is_item_checked(HANDLE_OPTION_ANGLE);
			mirror_handle_angle = !is_checked;
			pm->set_item_checked(HANDLE_OPTION_ANGLE, mirror_handle_angle);
			pm->set_item_disabled(HANDLE_OPTION_LENGTH, !mirror_handle_angle);
		} break;
		case HANDLE_OPTION_LENGTH: {
			bool is_checked = pm->is_item_checked(HANDLE_OPTION_LENGTH);
			mirror_handle_length = !is_checked;
			pm->set_item_checked(HANDLE_OPTION_LENGTH, mirror_handle_length);
		} break;
	}
}

void Path2DEditor::_confirm_clear_points() {
	if (!node || node->get_curve().is_null()) {
		return;
	}
	if (node->get_curve()->get_point_count() == 0) {
		return;
	}
	clear_points_dialog->reset_size();
	clear_points_dialog->popup_centered();
}

void Path2DEditor::_clear_curve_points(Path2D *p_path2d) {
	if (!p_path2d || p_path2d->get_curve().is_null()) {
		return;
	}
	Ref<Curve2D> curve = p_path2d->get_curve();

	if (curve->get_point_count() == 0) {
		return;
	}
	curve->clear_points();

	if (node == p_path2d) {
		_mode_selected(MODE_CREATE);
	}
}

void Path2DEditor::_restore_curve_points(Path2D *p_path2d, const PackedVector2Array &p_points) {
	if (!p_path2d || p_path2d->get_curve().is_null()) {
		return;
	}
	Ref<Curve2D> curve = p_path2d->get_curve();

	if (curve->get_point_count() > 0) {
		curve->clear_points();
	}

	for (int i = 0; i < p_points.size(); i += 3) {