From 7ee9de29a623cfb2a1efa70eb93e5b18bb8ed144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Mon, 17 Feb 2014 10:48:54 +0100 Subject: Fix T38487: Wrapped translate node in combination with other buffered nodes (Blur) causes crash due to chained read/write buffer operations. The way read/write buffer operations are created for both the wrapped translate node and then the "complex" blur node creates a chain of buffers in the same ExecutionGroup. This leaves the later write buffer operations without a proper "executor" group and fails on assert. Solution for now is to check for existing output buffer operations like it already happens for inputs. This is extremely ugly code, but should become a lot more transparent after compositor cleanup ({D309}). --- .../compositor/intern/COM_ExecutionSystem.cpp | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'source/blender/compositor') diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 6a208001f46..088232481d0 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -241,14 +241,34 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) */ OutputSocket *outputsocket = operation->getOutputSocket(); if (outputsocket->isConnected()) { - WriteBufferOperation *writeOperation; - writeOperation = new WriteBufferOperation(); - writeOperation->setbNodeTree(this->getContext().getbNodeTree()); - this->addOperation(writeOperation); - ExecutionSystemHelper::addLink(this->getConnections(), outputsocket, writeOperation->getInputSocket(0)); + WriteBufferOperation *writeOperation = NULL; + /* try to find existing write buffer operation first */ + for (index = 0; index < outputsocket->getNumberOfConnections(); index++) { + SocketConnection *connection = outputsocket->getConnection(index); + NodeBase *otherEnd = connection->getToNode(); + if (otherEnd->isOperation()) { + NodeOperation *otherEndOp = (NodeOperation *)otherEnd; + if (otherEndOp->isWriteBufferOperation()) { + writeOperation = (WriteBufferOperation *)otherEndOp; + break; + } + } + } + /* if no write buffer operation exists yet, create a new one */ + if (!writeOperation) { + writeOperation = new WriteBufferOperation(); + writeOperation->setbNodeTree(this->getContext().getbNodeTree()); + this->addOperation(writeOperation); + ExecutionSystemHelper::addLink(this->getConnections(), outputsocket, writeOperation->getInputSocket(0)); + } writeOperation->readResolutionFromInputSocket(); - for (index = 0; index < outputsocket->getNumberOfConnections() - 1; index++) { + + for (index = 0; index < outputsocket->getNumberOfConnections(); index++) { SocketConnection *connection = outputsocket->getConnection(index); + /* skip existing connections to write buffer operation */ + if (connection->getToNode() == writeOperation) + continue; + ReadBufferOperation *readoperation = new ReadBufferOperation(); readoperation->setMemoryProxy(writeOperation->getMemoryProxy()); connection->setFromSocket(readoperation->getOutputSocket()); -- cgit v1.2.3