2.5
authorTon Roosendaal <ton@blender.org>
Wed, 25 Feb 2009 09:54:41 +0000 (09:54 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 25 Feb 2009 09:54:41 +0000 (09:54 +0000)
Bugfix in compositor: code that duplicated the nodetree and merged
viewer images back lacked handling the case when a viewer was not
set active yet.

This fixes eternal loops in compositor after removing Viewers.

source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/node.c

index 360e1905ce81e30d237cba25a7b9a85df464da32..53b805f5f4c7eb027ab5b0952f3ae7162ba2310a 100644 (file)
@@ -351,12 +351,16 @@ void BKE_image_merge(Image *dest, Image *source)
 {
        ImBuf *ibuf;
        
-       while((ibuf= source->ibufs.first)) {
-               BLI_remlink(&source->ibufs, ibuf);
-               image_assign_ibuf(dest, ibuf, IMA_INDEX_PASS(ibuf->index), IMA_INDEX_FRAME(ibuf->index));
-       }
+       /* sanity check */
+       if(dest && source && dest!=source) {
        
-       free_libblock(&G.main->image, source);
+               while((ibuf= source->ibufs.first)) {
+                       BLI_remlink(&source->ibufs, ibuf);
+                       image_assign_ibuf(dest, ibuf, IMA_INDEX_PASS(ibuf->index), IMA_INDEX_FRAME(ibuf->index));
+               }
+               
+               free_libblock(&G.main->image, source);
+       }
 }
 
 
index 89d00cc8f062efdd2d98aadac06d7608b188910e..1e0abac915b06edbcf36cf5570c494ecc3f8da7e 100644 (file)
@@ -2490,8 +2490,11 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
                node->need_exec= 0;
                
                if(ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
-                       if(node->id && (node->flag & NODE_DO_OUTPUT)) {
-                               node->new_node->id= (ID *)BKE_image_copy((Image *)node->id);
+                       if(node->id) {
+                               if(node->flag & NODE_DO_OUTPUT)
+                                       node->new_node->id= (ID *)BKE_image_copy((Image *)node->id);
+                               else
+                                       node->new_node->id= NULL;
                        }
                }
                
@@ -2565,6 +2568,7 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
                        
                        if(ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
                                if(lnode->id && (lnode->flag & NODE_DO_OUTPUT)) {
+                                       /* image_merge does sanity check for pointers */
                                        BKE_image_merge((Image *)lnode->new_node->id, (Image *)lnode->id);
                                }
                        }