Skip to content

Commit

Permalink
Only try to create Component -> Component connections when both are i…
Browse files Browse the repository at this point in the history
…n the current change set

Since we display "virtual" Components of some things that aren't
actually in the current change set, we need to make sure that we don't
try to create a connection to them as that would effectively be a
dangling pointer.
  • Loading branch information
jhelwig authored and wendybujalski committed Jun 28, 2024
1 parent 2ce31f9 commit 5044d9b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/dal/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1939,14 +1939,34 @@ impl Component {
destination_input_socket_id: InputSocketId,
) -> ComponentResult<Option<AttributePrototypeArgumentId>> {
let total_start = std::time::Instant::now();
// Make sure both source & destination Components exist in the "current" change set.
// Eventually, this should probably be reported as an error actionable by the frontend, but
// for now, this is a no-op so we don't end up creating a broken graph.
let (_source_component, destination_component) = match (
Component::try_get_by_id(ctx, source_component_id).await?,
Component::try_get_by_id(ctx, destination_component_id).await?,
) {
(Some(source), Some(destination)) => (source, destination),
(source, destination) => {
warn!(
"Not creating edge; either source or destination component does not exist in current change set: {:?}, {:?}",
source,
destination,
);
return Ok(None);
}
};
// Already have this connection? Nothing to do.
let destination_component = Component::get_by_id(ctx, destination_component_id).await?;
for connection in destination_component.incoming_connections(ctx).await? {
if connection.from_component_id == source_component_id
&& connection.from_output_socket_id == source_output_socket_id
&& connection.to_component_id == destination_component_id
&& connection.to_input_socket_id == destination_input_socket_id
{
warn!(
"Not creating edge; already have this connection in change set: {:?}",
connection
);
return Ok(None);
}
}
Expand Down

0 comments on commit 5044d9b

Please sign in to comment.