Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3410,7 +3410,8 @@ impl NodeGraphMessageHandler {
.exports
.iter()
.any(|export| matches!(export, NodeInput::Node { node_id: export_node_id, .. } if *export_node_id == node_id));
if selection_is_not_already_the_output && no_other_selections {
let has_outputs = network_interface.number_of_outputs(&node_id, breadcrumb_network_path) > 0;
if selection_is_not_already_the_output && no_other_selections && has_outputs {
let button = TextButton::new("Preview")
.icon("FrameAll")
.tooltip_label("Preview")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3534,3 +3534,18 @@ async fn a_session_preview_of_a_removed_node_is_dropped() {
"The evaluated network should fall back to the document's own export"
);
}

#[tokio::test]
async fn cannot_preview_node_without_outputs() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;

let custom_node = editor.create_node_by_name_at(DefinitionIdentifier::Network("Custom Node".to_string()), 0, 0).await;
let network_interface = &mut editor.active_document_mut().network_interface;

assert_eq!(network_interface.number_of_outputs(&custom_node, &[]), 0);

// Attempting to toggle preview on a node without outputs should not enable previewing
network_interface.toggle_preview(custom_node, &[]);
assert_eq!(network_interface.previewing(&[]), Previewing::No);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1401,8 +1401,10 @@ impl NodeNetworkInterface {
let primary_output = RootNode { node_id: toggle_id, output_index: 0 };
let previewing = if self.previewing(network_path).previews(toggle_id) || self.root_node(network_path) == Some(primary_output) {
Previewing::No
} else {
} else if self.number_of_outputs(&toggle_id, network_path) > 0 {
Previewing::Yes { previewed: primary_output }
} else {
return;
};
self.set_previewing(previewing, network_path);
}
Expand Down
Loading