[Bf-blender-cvs] [75642b4cfd6] master: Fix T87252: File output node broken with more than 4 inputs.

Jeroen Bakker noreply at git.blender.org
Mon Apr 12 10:14:05 CEST 2021


Commit: 75642b4cfd654b97e8096b97add58c4afa218413
Author: Jeroen Bakker
Date:   Mon Apr 12 09:18:40 2021 +0200
Branches: master
https://developer.blender.org/rB75642b4cfd654b97e8096b97add58c4afa218413

Fix T87252: File output node broken with more than 4 inputs.

In recent refactor the operator sockets were migrated from a std::list to a blender::Vector.
The way how the file output node created the sockets along mapping the sockets could
lead to storing incorrect pointers.

This patch fixes this by defining and mapping the sockets in separate loops.

===================================================================

M	source/blender/compositor/nodes/COM_OutputFileNode.cc
M	source/blender/compositor/nodes/COM_OutputFileNode.h

===================================================================

diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cc b/source/blender/compositor/nodes/COM_OutputFileNode.cc
index 10f176d71f5..e5b9cfb8cc2 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.cc
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cc
@@ -18,7 +18,6 @@
 
 #include "COM_OutputFileNode.h"
 #include "COM_ExecutionSystem.h"
-#include "COM_OutputFileMultiViewOperation.h"
 #include "COM_OutputFileOperation.h"
 
 #include "BKE_scene.h"
@@ -32,6 +31,31 @@ OutputFileNode::OutputFileNode(bNode *editorNode) : Node(editorNode)
   /* pass */
 }
 
+void OutputFileNode::add_input_sockets(OutputOpenExrMultiLayerOperation &operation) const
+{
+  for (NodeInput *input : inputs) {
+    NodeImageMultiFileSocket *sockdata =
+        (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
+    /* note: layer becomes an empty placeholder if the input is not linked */
+    operation.add_layer(sockdata->layer, input->getDataType(), input->isLinked());
+  }
+}
+
+void OutputFileNode::map_input_sockets(NodeConverter &converter,
+                                       OutputOpenExrMultiLayerOperation &operation) const
+{
+  bool previewAdded = false;
+  int index = 0;
+  for (NodeInput *input : inputs) {
+    converter.mapInputSocket(input, operation.getInputSocket(index++));
+
+    if (!previewAdded) {
+      converter.addNodeInputPreview(input);
+      previewAdded = true;
+    }
+  }
+}
+
 void OutputFileNode::convertToOperations(NodeConverter &converter,
                                          const CompositorContext &context) const
 {
@@ -71,22 +95,11 @@ void OutputFileNode::convertToOperations(NodeConverter &converter,
     }
     converter.addOperation(outputOperation);
 
-    bool previewAdded = false;
-    int index = 0;
-    for (NodeInput *input : inputs) {
-      NodeImageMultiFileSocket *sockdata =
-          (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
-
-      /* note: layer becomes an empty placeholder if the input is not linked */
-      outputOperation->add_layer(sockdata->layer, input->getDataType(), input->isLinked());
-
-      converter.mapInputSocket(input, outputOperation->getInputSocket(index++));
-
-      if (!previewAdded) {
-        converter.addNodeInputPreview(input);
-        previewAdded = true;
-      }
-    }
+    /* First add all inputs. Inputs are stored in a Vector and can be moved to a different
+     * memory address during this time.*/
+    add_input_sockets(*outputOperation);
+    /* After adding the sockets the memory addresses will stick. */
+    map_input_sockets(converter, *outputOperation);
   }
   else { /* single layer format */
     bool previewAdded = false;
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.h b/source/blender/compositor/nodes/COM_OutputFileNode.h
index d1826797c6e..c64128a708f 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.h
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.h
@@ -19,6 +19,9 @@
 #pragma once
 
 #include "COM_Node.h"
+
+#include "COM_OutputFileMultiViewOperation.h"
+
 #include "DNA_node_types.h"
 
 namespace blender::compositor {
@@ -32,6 +35,11 @@ class OutputFileNode : public Node {
   OutputFileNode(bNode *editorNode);
   void convertToOperations(NodeConverter &converter,
                            const CompositorContext &context) const override;
+
+ private:
+  void add_input_sockets(OutputOpenExrMultiLayerOperation &operation) const;
+  void map_input_sockets(NodeConverter &converter,
+                         OutputOpenExrMultiLayerOperation &operation) const;
 };
 
 }  // namespace blender::compositor



More information about the Bf-blender-cvs mailing list