diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 47ca3e5ce0c..5b323a0a396 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -250,6 +250,7 @@ void ED_image_undo_restore(bContext *C, ListBase *lb) for (tile = lb->first; tile; tile = tile->next) { short use_float; + bool need_release = true; /* find image based on name, pointer becomes invalid with global undo */ if (ima && strcmp(tile->idname, ima->id.name) == 0) { @@ -268,8 +269,9 @@ void ED_image_undo_restore(bContext *C, ListBase *lb) * matched file name in list of already loaded images */ BKE_image_release_ibuf(ima, ibuf, NULL); + need_release = false; - ibuf = BLI_findstring(&ima->ibufs, tile->ibufname, offsetof(ImBuf, name)); + ibuf = BKE_image_get_ibuf_with_name(ima, tile->ibufname); } if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) { @@ -298,7 +300,12 @@ void ED_image_undo_restore(bContext *C, ListBase *lb) ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; - BKE_image_release_ibuf(ima, ibuf, NULL); + if (need_release) { + BKE_image_release_ibuf(ima, ibuf, NULL); + } + else { + IMB_freeImBuf(ibuf); + } } IMB_freeImBuf(tmpibuf); |