[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32760] trunk/blender/source/blender: bugfix for grease pencil freeing order.

Campbell Barton ideasman42 at gmail.com
Fri Oct 29 09:12:02 CEST 2010


Revision: 32760
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32760
Author:   campbellbarton
Date:     2010-10-29 09:11:45 +0200 (Fri, 29 Oct 2010)

Log Message:
-----------
bugfix for grease pencil freeing order.
it was freed before objects which would then decrease its usercount - accessing freed memory.

Also fixed error in own last commit.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/library.c
    trunk/blender/source/blender/makesrna/intern/rna_image.c

Modified: trunk/blender/source/blender/blenkernel/intern/library.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/library.c	2010-10-28 21:20:57 UTC (rev 32759)
+++ trunk/blender/source/blender/blenkernel/intern/library.c	2010-10-29 07:11:45 UTC (rev 32760)
@@ -452,11 +452,13 @@
 {
 	int a = 0;
 
-	/* BACKWARDS! also watch order of free-ing! (mesh<->mat) */
-
+	/* BACKWARDS! also watch order of free-ing! (mesh<->mat), first items freed last.
+	 * This is important because freeing data decreases usercounts of other datablocks,
+	 * if this data is its self freed it can crash. */
 	lb[a++]= &(main->ipo);
 	lb[a++]= &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith)
 	lb[a++]= &(main->key);
+	lb[a++]= &(main->gpencil); /* referenced by nodes, objects, view, scene etc, before to free after. */
 	lb[a++]= &(main->nodetree);
 	lb[a++]= &(main->image);
 	lb[a++]= &(main->tex);
@@ -483,14 +485,13 @@
 	lb[a++]= &(main->brush);
 	lb[a++]= &(main->script);
 	lb[a++]= &(main->particle);
-	
+
 	lb[a++]= &(main->world);
 	lb[a++]= &(main->screen);
 	lb[a++]= &(main->object);
 	lb[a++]= &(main->scene);
 	lb[a++]= &(main->library);
 	lb[a++]= &(main->wm);
-	lb[a++]= &(main->gpencil);
 	
 	lb[a]= NULL;
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_image.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_image.c	2010-10-28 21:20:57 UTC (rev 32759)
+++ trunk/blender/source/blender/makesrna/intern/rna_image.c	2010-10-29 07:11:45 UTC (rev 32760)
@@ -181,7 +181,7 @@
 		*/
 
 		/* to be safe change all buffer file types */
-		for(ibuf= image->ibufs.first; ibuf; ibuf->next) {
+		for(ibuf= image->ibufs.first; ibuf; ibuf= ibuf->next) {
 			ibuf->ftype= ftype;
 		}
 	}





More information about the Bf-blender-cvs mailing list