From a9fbd05e7d40eb19d9ef8939dd6341386767cd44 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Oct 2019 11:47:11 +1100 Subject: Fix image undo restoring float/byte tiles into the wrong buffer type This also resolves the (unlikely) issue of undo having uninitialized zbuf data, now it's cleared instead. --- source/blender/imbuf/intern/allocimbuf.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'source/blender/imbuf/intern/allocimbuf.c') diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 75db3fd3c73..381de9de610 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -197,6 +197,17 @@ void IMB_freezbuffloatImBuf(ImBuf *ibuf) ibuf->mall &= ~IB_zbuffloat; } +/** Free all pixel data (assosiated with image size). */ +void imb_freerectImbuf_all(ImBuf *ibuf) +{ + imb_freerectImBuf(ibuf); + imb_freerectfloatImBuf(ibuf); + imb_freetilesImBuf(ibuf); + IMB_freezbufImBuf(ibuf); + IMB_freezbuffloatImBuf(ibuf); + freeencodedbufferImBuf(ibuf); +} + void IMB_freeImBuf(ImBuf *ibuf) { if (ibuf) { @@ -212,12 +223,7 @@ void IMB_freeImBuf(ImBuf *ibuf) BLI_spin_unlock(&refcounter_spin); if (needs_free) { - imb_freerectImBuf(ibuf); - imb_freerectfloatImBuf(ibuf); - imb_freetilesImBuf(ibuf); - IMB_freezbufImBuf(ibuf); - IMB_freezbuffloatImBuf(ibuf); - freeencodedbufferImBuf(ibuf); + imb_freerectImbuf_all(ibuf); IMB_metadata_free(ibuf->metadata); colormanage_cache_free(ibuf); -- cgit v1.2.3