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.
This commit is contained in:
Bastien Montagne 2021-08-19 17:04:19 +02:00
parent 214e4aac97
commit 0896457c59
Notes: blender-bot 2023-02-14 10:21:11 +01:00
Referenced by issue #97015, Undo incorrectly frees all the ImBufs of tiled images
Referenced by issue #90593, Undo takes several seconds just to move default cube within scene containing panorama if viewport shows materials
1 changed files with 14 additions and 0 deletions

View File

@ -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);
}