Fix (unreported) broken ID previews reading.

Recent changes to blendfile reading adding deferred reading of actual
data broke it, we cannot use the nifty `bhead + 1` to access data
anymore, since there is no guaranty that that block hass been fully
read.

Note that there is still one case in `read_file_thumbnail()`, however
loading of blendfile preview itself seems to be working fine... Maybe
@campbellbarton can double check that point (or knows of hands whether
it is OK there)?
This commit is contained in:
Bastien Montagne 2019-03-11 17:05:03 +01:00
parent 1bc8ddbc6c
commit 93633efe69
Notes: blender-bot 2024-03-22 15:57:27 +01:00
Referenced by commit 5ae8b1da02, Fix wrong memory handling in own rB93633efe69ca.
1 changed files with 2 additions and 2 deletions

View File

@ -204,7 +204,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
size_t len = new_prv->w[0] * new_prv->h[0] * sizeof(uint);
new_prv->rect[0] = MEM_callocN(len, __func__);
bhead = blo_bhead_next(fd, bhead);
rect = (uint *)(bhead + 1);
rect = BLO_library_read_struct(fd, bhead, "PreviewImage Icon Rect");
BLI_assert(len == bhead->len);
memcpy(new_prv->rect[0], rect, len);
}
@ -221,7 +221,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
size_t len = new_prv->w[1] * new_prv->h[1] * sizeof(uint);
new_prv->rect[1] = MEM_callocN(len, __func__);
bhead = blo_bhead_next(fd, bhead);
rect = (uint *)(bhead + 1);
rect = BLO_library_read_struct(fd, bhead, "PreviewImage Image Rect");
BLI_assert(len == bhead->len);
memcpy(new_prv->rect[1], rect, len);
}