Repository: godot
Issue: VisualShader: Crash when converting float constants to parameters then undoing and redoing
Labels: bug,topic:editor,crash,topic:shaders

### Tested versions

4.3stable
master (custom build based on https://github.com/godotengine/godot/commit/c3e16cda00a9fbec4515142f4c59bc5134f1bfb0)

### System information

Godot v4.3.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1660 Ti with Max-Q Design (NVIDIA; 32.0.15.5612) - AMD Ryzen 7 3750H with Radeon Vega Mobile Gfx (8 Threads)

### Issue description

When converting one or more FloatConstants to FloatParameters in VisualShader, then undoing and redoing, Godot will crash.

Crash seems to relate to the undo/redo code in https://github.com/godotengine/godot/blob/c3e16cda00a9fbec4515142f4c59bc5134f1bfb0/editor/plugins/visual_shader_editor_plugin.cpp#L4403

This log is from a custom build. I was making changes in this `_convert_constants_to_parameters` function, but the crash still happens when I remove my changes, and happens consistently in 4.3 as well. (To be clear, the log is from a build with no changes to the function)
```

ERROR: Parameter "sd" is null.
   at: TextServerAdvanced::_shaped_text_get_glyph_count (modules\text_server_adv\text_server_adv.cpp:6554)
ERROR: Parameter "sd" is null.
   at: TextServerAdvanced::_shaped_text_get_glyphs (modules\text_server_adv\text_server_adv.cpp:6543)
ERROR: Parameter "sd" is null.
   at: TextServerAdvanced::_shaped_text_get_glyph_count (modules\text_server_adv\text_server_adv.cpp:6554)
ERROR: Parameter "sd" is null.
   at: TextServerAdvanced::_shaped_text_get_glyphs (modules\text_server_adv\text_server_adv.cpp:6543)
ERROR: Parameter "sd" is null.
   at: TextServerAdvanced::_shaped_text_get_glyph_count (modules\text_server_adv\text_server_adv.cpp:6554)
ERROR: Parameter "sd" is null.
   at: TextServerAdvanced::_shaped_text_get_glyphs (modules\text_server_adv\text_server_adv.cpp:6543)
ERROR: Parameter "sd" is null.
   at: TextServerAdvanced::_shaped_text_get_size (modules\text_server_adv\text_server_adv.cpp:6645)

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.4.dev.custom_build (0c6c836a95d02191d46af3c684f1508eefbde1fe)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] StyleBox::get_margin (C:\Users\admin\Documents\GitHub\godot\scene\resources\style_box.cpp:81)
[1] LineEdit::set_caret_column (C:\Users\admin\Documents\GitHub\godot\scene\gui\line_edit.cpp:1920)
[2] LineEdit::insert_text_at_caret (C:\Users\admin\Documents\GitHub\godot\scene\gui\line_edit.cpp:1998)
[3] LineEdit::set_text (C:\Users\admin\Documents\GitHub\godot\scene\gui\line_edit.cpp:1747)
[4] VisualShaderGraphPlugin::set_parameter_name (C:\Users\admin\Documents\GitHub\godot\editor\plugins\visual_shader_editor_plugin.cpp:327)
[5] VisualShaderEditor::_update_parameter (C:\Users\admin\Documents\GitHub\godot\editor\plugins\visual_shader_editor_plugin.cpp:4403)
[6] call_with_variant_args_helper<VisualShaderEditor,enum VisualShader::Type,int,Variant const &,int,0,1,2,3> (C:\Users\admin\Documents\GitHub\godot\core\variant\binder_common.h:304)
[7] call_with_variant_args_dv<VisualShaderEditor,enum VisualShader::Type,int,Variant const &,int> (C:\Users\admin\Documents\GitHub\godot\core\variant\binder_common.h:451)
[8] MethodBindT<VisualShaderEditor,enum VisualShader::Type,int,Variant const &,int>::call (C:\Users\admin\Documents\GitHub\godot\core\object\method_bind.h:347)
[9] Object::callp (C:\Users\admin\Documents\GitHub\godot\core\object\object.cpp:813)
[10] Callable::callp (C:\Users\admin\Documents\GitHub\godot\core\variant\callable.cpp:69)
[11] CallableCustomBind::call (C:\Users\admin\Documents\GitHub\godot\core\variant\callable_bind.cpp:152)
[12] Callable::callp (C:\Users\admin\Documents\GitHub\godot\core\variant\callable.cpp:57)
[13] UndoRedo::_process_operation_list (C:\Users\admin\Documents\GitHub\godot\core\object\undo_redo.cpp:365)
[14] UndoRedo::_redo (C:\Users\admin\Documents\GitHub\godot\core\object\undo_redo.cpp:82)
[15] UndoRedo::redo (C:\Users\admin\Documents\GitHub\godot\core\object\undo_redo.cpp:423)
[16] EditorUndoRedoManager::redo_history (C:\Users\admin\Documents\GitHub\godot\editor\editor_undo_redo_manager.cpp:349)
[17] EditorUndoRedoManager::redo (C:\Users\admin\Documents\GitHub\godot\editor\editor_undo_redo_manager.cpp:336)
[18] EditorNode::_menu_option_confirm (C:\Users\admin\Documents\GitHub\godot\editor\editor_node.cpp:2860)
[19] EditorNode::_menu_option (C:\Users\admin\Documents\GitHub\godot\editor\editor_node.cpp:1445)
[20] call_with_variant_args_helper<EditorNode,int,0> (C:\Users\admin\Documents\GitHub\godot\core\variant\binder_common.h:304)
[21] call_with_variant_args<EditorNode,int> (C:\Users\admin\Documents\GitHub\godot\core\variant\binder_common.h:418)
[22] CallableCustomMethodPointer<EditorNode,int>::call (C:\Users\admin\Documents\GitHub\godot\core\object\callable_method_pointer.h:103)
[23] Callable::callp (C:\Users\admin\Documents\GitHub\godot\core\variant\callable.cpp:57)
[24] Object::emit_signalp (C:\Users\admin\Documents\GitHub\godot\core\object\object.cpp:1201)
[25] Node::emit_signalp (C:\Users\admin\Documents\GitHub\godot\scene\main\node.cpp:3975)
[26] Object::emit_signal<int> (C:\Users\admin\Documents\GitHub\godot\core\object\object.h:921)
[27] PopupMenu::activate_item (C:\Users\admin\Documents\GitHub\godot\scene\gui\popup_menu.cpp:2437)
[28] PopupMenu::activate_item_by_event (C:\Users\admin\Documents\GitHub\godot\scene\gui\popup_menu.cpp:2359)
[29] MenuBar::shortcut_input (C:\Users\admin\Documents\GitHub\godot\scene\gui\menu_bar.cpp:167)
[30] Node::_call_shortcut_input (C:\Users\admin\Documents\GitHub\godot\scene\main\node.cpp:3435)
[31] SceneTree::_call_input_pause (C:\Users\admin\Documents\GitHub\godot\scene\main\scene_tree.cpp:1300)
[32] Viewport::_push_unhandled_input_internal (C:\Users\admin\Documents\GitHub\godot\scene\main\viewport.cpp:3220)
[33] Viewport::push_input (C:\Users\admin\Documents\GitHub\godot\scene\main\viewport.cpp:3182)
[34] Window::_window_input (C:\Users\admin\Documents\GitHub\godot\scene\main\window.cpp:1680)
[35] call_with_variant_args_helper<Window,Ref<InputEvent> const &,0> (C:\Users\admin\Documents\GitHub\godot\core\variant\binder_common.h:304)
[36] call_with_variant_args<Window,Ref<InputEvent> const &> (C:\Users\admin\Documents\GitHub\godot\core\variant\binder_common.h:418)
[37] CallableCustomMethodPointer<Window,Ref<InputEvent> const &>::call (C:\Users\admin\Documents\GitHub\godot\core\object\callable_method_pointer.h:103)
[38] Callable::callp (C:\Users\admin\Documents\GitHub\godot\core\variant\callable.cpp:57)
[39] Callable::call<Ref<InputEvent> > (C:\Users\admin\Documents\GitHub\godot\core\variant\variant.h:875)
[40] DisplayServerWindows::_dispatch_input_event (C:\Users\admin\Documents\GitHub\godot\platform\windows\display_server_windows.cpp:3733)
[41] DisplayServerWindows::_dispatch_input_events (C:\Users\admin\Documents\GitHub\godot\platform\windows\display_server_windows.cpp:3703)
[42] Input::_parse_input_event_impl (C:\Users\admin\Documents\GitHub\godot\core\input\input.cpp:803)
[43] Input::flush_buffered_events (C:\Users\admin\Documents\GitHub\godot\core\input\input.cpp:1084)
[44] DisplayServerWindows::process_events (C:\Users\admin\Documents\GitHub\godot\platform\windows\display_server_windows.cpp:3183)
[45] OS_Windows::run (C:\Users\admin\Documents\GitHub\godot\platform\windows\os_windows.cpp:1771)
[46] widechar_main (C:\Users\admin\Documents\GitHub\godot\platform\windows\godot_windows.cpp:180)
[47] _main (C:\Users\admin\Documents\GitHub\godot\platform\windows\godot_windows.cpp:206)
[48] main (C:\Users\admin\Documents\GitHub\godot\platform\windows\godot_windows.cpp:220)
[49] WinMain (C:\Users\admin\Documents\GitHub\godot\platform\windows\godot_windows.cpp:234)
[50] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[51] <couldn't map PC to fn name>
-- END OF BACKTRACE --
```

### Steps to reproduce

Create a new visual shader.
Add a FloatConstant node.
Select the node, right click and "Convert Constant(s) to Parameter(s)".
Undo with `ctrl+z`.
Redo with `ctrl+y`.
Observe crash.

It may be easier to reproduce if you add several FloatConstants and mass convert.
Repeatedly undoing and redoing may also help reproduce.

### Minimal reproduction project (MRP)

N/A