@@ -3908,6 +3908,37 @@ mod document_message_handler_tests {
39083908 editor. handle_message ( DocumentMessage :: CreateEmptyFolder ) . await ;
39093909 assert ! ( true , "Application didn't crash after folder move operation" ) ;
39103910 }
3911+
3912+ // Merging nodes whose output isn't wired downstream produces an encapsulating subnetwork with no exports.
3913+ // Inspecting it via the Data panel (which splices in a monitor node) must not leave a dangling reference that crashes compilation.
3914+ #[ tokio:: test]
3915+ async fn merge_selected_nodes_while_inspecting_does_not_crash ( ) {
3916+ let mut editor = EditorTestUtils :: create ( ) ;
3917+ editor. new_document ( ) . await ;
3918+ editor. draw_rect ( 0. , 0. , 100. , 100. ) . await ;
3919+
3920+ let node_a = editor. create_node_by_name ( DefinitionIdentifier :: ProtoNode ( graphene_std:: transform_nodes:: transform:: IDENTIFIER ) ) . await ;
3921+ let node_b = editor. create_node_by_name ( DefinitionIdentifier :: ProtoNode ( graphene_std:: transform_nodes:: transform:: IDENTIFIER ) ) . await ;
3922+ editor. handle_message ( NodeGraphMessage :: SelectedNodesSet { nodes : vec ! [ node_a, node_b] } ) . await ;
3923+ editor. handle_message ( NodeGraphMessage :: MergeSelectedNodes ) . await ;
3924+
3925+ let merged = editor. active_document ( ) . network_interface . selected_nodes_in_nested_network ( & [ ] ) . unwrap ( ) . 0 . clone ( ) ;
3926+ assert_eq ! ( merged. len( ) , 1 , "merge should leave one encapsulating node selected" ) ;
3927+
3928+ // Simulate the Data panel inspecting the merged node, which compiles the graph with a monitor node spliced in
3929+ let portfolio = & mut editor. editor . dispatcher . message_handlers . portfolio_message_handler ;
3930+ let document_id = portfolio. active_document_id . unwrap ( ) ;
3931+ let document = portfolio. documents . get_mut ( & document_id) . unwrap ( ) ;
3932+ portfolio
3933+ . executor
3934+ . submit_node_graph_evaluation ( document, document_id, glam:: UVec2 :: ONE , 1. , Default :: default ( ) , merged, true , DVec2 :: ZERO )
3935+ . unwrap ( ) ;
3936+ editor. runtime . run ( ) . await ;
3937+
3938+ let mut messages = VecDeque :: new ( ) ;
3939+ editor. editor . poll_node_graph_evaluation ( & mut messages) . unwrap ( ) ;
3940+ }
3941+
39113942 #[ tokio:: test]
39123943 async fn test_moving_folder_with_children ( ) {
39133944 let mut editor = EditorTestUtils :: create ( ) ;
0 commit comments