From 0896457c59d722e809188517c042b57d0ea399d3 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 19 Aug 2021 17:04:19 +0200 Subject: Partially fix T90593: Image ID wrongly seen as changed on undos. Several pure runtime data in this ID type were not properly cleared by write/read processes. Note that the initial undo step (the one leading back to initial read file state) is still forcing re-load of image, for some reasons. Common investigation together with Jeroen Bakker (@jbakker), thanks. See also D12242. --- source/blender/blenkernel/intern/image.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index de9f2a5a656..f37073ff135 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -230,6 +230,19 @@ static void image_blend_write(BlendWriter *writer, ID *id, const void *id_addres Image *ima = (Image *)id; const bool is_undo = BLO_write_is_undo(writer); + /* Clear all data that isn't read to reduce false detection of changed image during memfile undo. + */ + ima->lastused = 0; + ima->cache = NULL; + ima->gpuflag = 0; + BLI_listbase_clear(&ima->anims); + BLI_listbase_clear(&ima->gpu_refresh_areas); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 2; j++) { + ima->gputexture[i][j] = NULL; + } + } + ImagePackedFile *imapf; BLI_assert(ima->packedfile == NULL); @@ -299,6 +312,7 @@ static void image_blend_read_data(BlendDataReader *reader, ID *id) LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) { tile->ok = IMA_OK; } + ima->lastused = 0; ima->gpuflag = 0; BLI_listbase_clear(&ima->gpu_refresh_areas); } -- cgit v1.2.3