diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-15 12:01:49 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-15 12:01:49 +0400 |
commit | ca9ae04220560191c11c3657466cfaa42f7effc6 (patch) | |
tree | 12875cf471b1e459a3295bef79418db40677d83d | |
parent | 9e4d9e066ade129c191c8cd6efe7b417f578abce (diff) |
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.
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index d557a3bd144..060cae48fa0 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -383,7 +383,7 @@ typedef struct UndoImageTile { void *rect; int x, y; - short source; + short source, use_float; char gen_type; } UndoImageTile; @@ -413,11 +413,13 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int 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 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int 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 @@ static void image_undo_restore(bContext *C, ListBase *lb) 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 @@ static void image_undo_restore(bContext *C, ListBase *lb) } 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 @@ static void image_undo_restore(bContext *C, ListBase *lb) 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 */ |