[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40456] trunk/blender/source/blender/ editors/interface/interface.c: Fix #28593: F6 operator redo could crash when editing buttons that use unit

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Sep 22 16:55:40 CEST 2011


Revision: 40456
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40456
Author:   blendix
Date:     2011-09-22 14:55:39 +0000 (Thu, 22 Sep 2011)
Log Message:
-----------
Fix #28593: F6 operator redo could crash when editing buttons that use unit
settings, these could get freed with the scene on undo/redo, make a copy now.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface.c

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2011-09-22 14:42:29 UTC (rev 40455)
+++ trunk/blender/source/blender/editors/interface/interface.c	2011-09-22 14:55:39 UTC (rev 40456)
@@ -1935,6 +1935,9 @@
 		ui_free_but(C, but);
 	}
 
+	if(block->unit)
+		MEM_freeN(block->unit);
+
 	if(block->func_argN)
 		MEM_freeN(block->func_argN);
 
@@ -2010,10 +2013,15 @@
 	block->active= 1;
 	block->dt= dt;
 	block->evil_C= (void*)C; // XXX
+
 	if (scn) {
 		block->color_profile= (scn->r.color_mgt_flag & R_COLOR_MANAGEMENT);
-		block->unit= &scn->unit;
+
+		/* copy to avoid crash when scene gets deleted with ui still open */
+		block->unit= MEM_mallocN(sizeof(scn->unit), "UI UnitSettings");
+		memcpy(block->unit, &scn->unit, sizeof(scn->unit));
 	}
+
 	BLI_strncpy(block->name, name, sizeof(block->name));
 
 	if(region)




More information about the Bf-blender-cvs mailing list