[Bf-blender-cvs] [ca98aca] GPencil_EditStrokes: Quick hacky fix for crash on undo (for Grease Pencil)

Joshua Leung noreply at git.blender.org
Sat Nov 29 12:13:52 CET 2014


Commit: ca98aca565774afc524b7b1ba505196574ce5091
Author: Joshua Leung
Date:   Sun Nov 30 00:08:14 2014 +1300
Branches: GPencil_EditStrokes
https://developer.blender.org/rBca98aca565774afc524b7b1ba505196574ce5091

Quick hacky fix for crash on undo (for Grease Pencil)

AnimData is not copied when making duplicating bGPdata for internal usage
(i.e. for the undo buffer); instead, the data was being shared between the
real copies and the undo buffer copies (to save memory - since otherwise
we'd have to have copies of all the animation data floating around).

The fix here clears these refs before trying to free these copies,
making sure that the data won't get freed incorrectly.

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

M	source/blender/editors/gpencil/gpencil_undo.c

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

diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c
index 9a71c65..b1bbeab 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -133,7 +133,12 @@ void gpencil_undo_push(bGPdata *gpd)
 
 		while (undo_node) {
 			bGPundonode *next_node = undo_node->next;
-
+			
+			/* HACK: animdata wasn't duplicated, so it shouldn't be freed here,
+			 * or else the real copy will segfault when accessed 
+			 */
+			undo_node->gpd->adt = NULL;
+			
 			BKE_gpencil_free(undo_node->gpd);
 			MEM_freeN(undo_node->gpd);
 
@@ -157,6 +162,11 @@ void gpencil_undo_finish(void)
 	bGPundonode *undo_node = undo_nodes.first;
 
 	while (undo_node) {
+		/* HACK: animdata wasn't duplicated, so it shouldn't be freed here,
+		 * or else the real copy will segfault when accessed 
+		 */
+		undo_node->gpd->adt = NULL;
+		
 		BKE_gpencil_free(undo_node->gpd);
 		MEM_freeN(undo_node->gpd);




More information about the Bf-blender-cvs mailing list