fix [#32490] Compsitor crashes on missing OpenEXR multilayer files

This commit is contained in:
Campbell Barton
2012-09-04 19:42:09 +00:00
parent 306e2b4878
commit 1d4316f35f
5 changed files with 35 additions and 10 deletions

View File

@@ -137,6 +137,21 @@ void Node::addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocke
graph->addOperation(operation);
}
/* when a node has no valid data (missing image or group pointer) */
void Node::convertToOperations_invalid(ExecutionSystem *graph, CompositorContext *context)
{
/* this is a really bad situation - bring on the pink! - so artists know this is bad */
const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
int index;
vector<OutputSocket *> &outputsockets = this->getOutputSockets();
for (index = 0; index < outputsockets.size(); index++) {
SetColorOperation *operation = new SetColorOperation();
this->getOutputSocket(index)->relinkConnections(operation->getOutputSocket());
operation->setChannels(warning_color);
graph->addOperation(operation);
}
}
bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
{
bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->inputs.first;

View File

@@ -99,6 +99,13 @@ public:
*/
void addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex);
/**
* when a node has no valid data (missing image or a group nodes ID pointer is NULL)
* call this function from #convertToOperations, this way the node sockets are converted
* into valid outputs, without this the compositor system gets confused and crashes, see [#32490]
*/
void convertToOperations_invalid(ExecutionSystem *graph, CompositorContext *context);
/**
* Creates a new link between an outputSocket and inputSocket and registrates the link to the graph
* @return the new created link

View File

@@ -33,16 +33,7 @@ GroupNode::GroupNode(bNode *editorNode) : Node(editorNode)
void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
if (this->getbNode()->id == NULL) {
/* this is a really bad situation - bring on the pink! - so artists know this is bad */
const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
int index;
vector<OutputSocket *> &outputsockets = this->getOutputSockets();
for (index = 0; index < outputsockets.size(); index++) {
SetColorOperation *operation = new SetColorOperation();
this->getOutputSocket(index)->relinkConnections(operation->getOutputSocket());
operation->setChannels(warning_color);
graph->addOperation(operation);
}
convertToOperations_invalid(graph, context);
}
}

View File

@@ -72,12 +72,16 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
/* force a load, we assume iuser index will be set OK anyway */
if (image && image->type == IMA_TYPE_MULTILAYER) {
bool is_multilayer_ok = false;
BKE_image_get_ibuf(image, imageuser);
if (image->rr) {
RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer);
if (rl) {
OutputSocket *socket;
int index;
is_multilayer_ok = true;
for (index = 0; index < numberOfOutputs; index++) {
socket = this->getOutputSocket(index);
if (socket->isConnected() || index == 0) {
@@ -114,6 +118,11 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
}
}
}
/* without this, multilayer that fail to load will crash blender [#32490] */
if (is_multilayer_ok == false) {
convertToOperations_invalid(graph, context);
}
}
else {
if (numberOfOutputs > 0) {

View File

@@ -31,6 +31,9 @@
*/
class CompositorOperation : public NodeOperation {
private:
/**
* @brief Scene name, used for getting the render output, includes 'SC' prefix.
*/
char m_sceneName[MAX_ID_NAME];
/**