Fix #138001: File output node with no inputs crash
Blender crashes when rendering a scene that has a file output node with no inputs. That's because the preview code assumes that nodes would always have inputs. So we simply guard against this case.
This commit is contained in:
@@ -64,9 +64,8 @@ class NodeOperation : public Operation {
|
||||
|
||||
private:
|
||||
/* Get the result which will be previewed in the node, this is chosen as the first linked output
|
||||
* of the node, if no outputs exist, then the first allocated input will be chosen. Nullptr is
|
||||
* guaranteed not to be returned, since the node will always either have a linked output or an
|
||||
* allocated input. */
|
||||
* of the node, if no outputs exist, then the first allocated input will be chosen. Returns
|
||||
* nullptr if no result is viewable. */
|
||||
Result *get_preview_result();
|
||||
};
|
||||
|
||||
|
||||
@@ -59,7 +59,10 @@ void NodeOperation::evaluate()
|
||||
void NodeOperation::compute_preview()
|
||||
{
|
||||
if (bool(context().needed_outputs() & OutputTypes::Previews) && is_node_preview_needed(node())) {
|
||||
compositor::compute_preview(context(), node(), *get_preview_result());
|
||||
const Result *result = get_preview_result();
|
||||
if (result) {
|
||||
compositor::compute_preview(context(), node(), *result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +80,12 @@ Result *NodeOperation::get_preview_result()
|
||||
}
|
||||
}
|
||||
|
||||
/* No linked outputs, find the first allocated input. */
|
||||
/* No linked outputs, but no inputs either, so nothing to preview. */
|
||||
if (node()->input_sockets().is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Find the first allocated input. */
|
||||
for (const bNodeSocket *input : node()->input_sockets()) {
|
||||
if (!input->is_available()) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user