[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42638] trunk/blender/source/blender/ editors/sculpt_paint/paint_image.c: Fix #29615: Crash during undo after toggling "Float buffer" in image paint mode

Sergey Sharybin sergey.vfx at gmail.com
Thu Dec 15 09:01:50 CET 2011


Revision: 42638
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42638
Author:   nazgul
Date:     2011-12-15 08:01:49 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------
Fix #29615: Crash during undo after toggling "Float buffer" in image paint mode

Crash was caused by different types of buffers stored in tile in undo stack and in
image itself. Store type of buffer in tile, so byte tile wouldn't be applying on
float image anymore.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2011-12-15 07:54:13 UTC (rev 42637)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2011-12-15 08:01:49 UTC (rev 42638)
@@ -383,7 +383,7 @@
 	void *rect;
 	int x, y;
 
-	short source;
+	short source, use_float;
 	char gen_type;
 } UndoImageTile;
 
@@ -413,11 +413,13 @@
 	ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_IMAGE);
 	UndoImageTile *tile;
 	int allocsize;
+	short use_float = ibuf->rect_float ? 1 : 0;
 
 	for(tile=lb->first; tile; tile=tile->next)
 		if(tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source)
-			if(strcmp(tile->idname, ima->id.name)==0 && strcmp(tile->ibufname, ibuf->name)==0)
-				return tile->rect;
+			if(tile->use_float == use_float)
+				if(strcmp(tile->idname, ima->id.name)==0 && strcmp(tile->ibufname, ibuf->name)==0)
+					return tile->rect;
 	
 	if (*tmpibuf==NULL)
 		*tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat|IB_rect);
@@ -435,6 +437,7 @@
 
 	tile->gen_type= ima->gen_type;
 	tile->source= ima->source;
+	tile->use_float= use_float;
 
 	undo_copy_tile(tile, *tmpibuf, ibuf, 0);
 	undo_paint_push_count_alloc(UNDO_PAINT_IMAGE, allocsize);
@@ -455,6 +458,8 @@
 							IB_rectfloat|IB_rect);
 	
 	for(tile=lb->first; tile; tile=tile->next) {
+		short use_float;
+
 		/* find image based on name, pointer becomes invalid with global undo */
 		if(ima && strcmp(tile->idname, ima->id.name)==0) {
 			/* ima is valid */
@@ -464,6 +469,7 @@
 		}
 
 		ibuf= BKE_image_get_ibuf(ima, NULL);
+		use_float = ibuf->rect_float ? 1 : 0;
 
 		if(ima && ibuf && strcmp(tile->ibufname, ibuf->name)!=0) {
 			/* current ImBuf filename was changed, probably current frame
@@ -480,6 +486,9 @@
 		if (ima->gen_type != tile->gen_type || ima->source != tile->source)
 			continue;
 
+		if (use_float != tile->use_float)
+			continue;
+
 		undo_copy_tile(tile, tmpibuf, ibuf, 1);
 
 		GPU_free_image(ima); /* force OpenGL reload */




More information about the Bf-blender-cvs mailing list