[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36290] trunk/blender/source/blender/ blenkernel/intern/node.c: Fix for group output memory leak, bug #27104.

Lukas Toenne lukas.toenne at googlemail.com
Sat Apr 23 09:21:11 CEST 2011


Revision: 36290
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36290
Author:   lukastoenne
Date:     2011-04-23 07:21:10 +0000 (Sat, 23 Apr 2011)
Log Message:
-----------
Fix for group output memory leak, bug #27104. This happens when an internal node in a group has multiple output buffers, but only some of them are used. Then all the buffers would be created, but the unlinked outputs were not correctly tagged for freeing after group execution.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/node.c

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2011-04-23 07:04:50 UTC (rev 36289)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2011-04-23 07:21:10 UTC (rev 36290)
@@ -1997,11 +1997,23 @@
 	if (ntree->type==NTREE_COMPOSIT) {
 		bNodeSocket *sock;
 		bNodeStack *ns;
+		
+		/* clear hasoutput on all local stack data,
+		 * only the group output will be used from now on
+		 */
+		for (node=ntree->nodes.first; node; node=node->next) {
+			for (sock=node->outputs.first; sock; sock=sock->next) {
+				if (sock->stack_type==SOCK_STACK_LOCAL) {
+					ns= get_socket_stack(stack, sock, in);
+					ns->hasoutput = 0;
+				}
+			}
+		}
+		/* use the hasoutput flag to tag external sockets */
 		for (sock=ntree->outputs.first; sock; sock=sock->next) {
-			/* use the hasoutput flag to tag external sockets */
 			if (sock->stack_type==SOCK_STACK_LOCAL) {
 				ns= get_socket_stack(stack, sock, in);
-				ns->hasoutput = 0;
+				ns->hasoutput = 1;
 			}
 		}
 		/* now free all stacks that are not used from outside */
@@ -2009,11 +2021,9 @@
 			for (sock=node->outputs.first; sock; sock=sock->next) {
 				if (sock->stack_type==SOCK_STACK_LOCAL ) {
 					ns= get_socket_stack(stack, sock, in);
-					if (ns->hasoutput!=0 && ns->data) {
+					if (ns->hasoutput==0 && ns->data) {
 						free_compbuf(ns->data);
 						ns->data = NULL;
-						/* reset the flag */
-						ns->hasoutput = 1;
 					}
 				}
 			}




More information about the Bf-blender-cvs mailing list