diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-19 17:29:58 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-19 17:40:04 +0300 |
commit | 38f0d5f75af7d2f30156f4008dc5bc8d8394fbf3 (patch) | |
tree | e4c46983e63fa98f75b61f9cc08e3c667586e24c /source/blender | |
parent | 22eeae8104505b176cee5b9bba2071303b4465ea (diff) |
Fix T61714, T61712: crash reloading images after recent changes.
Now that we are looping over all image users that were previously ignored,
it shows some scene pointers are invalid. Always clear them on load, and
don't keep scene permanently in the image user except for the image editor.
Otherwise the pointer can go out of date.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 22 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw_legacy.c | 13 |
2 files changed, 26 insertions, 9 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 7f8c224114d..310c6876b2f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3319,6 +3319,16 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) NodeShaderTexPointDensity *npd = (NodeShaderTexPointDensity *)node->storage; memset(&npd->pd, 0, sizeof(npd->pd)); } + else if (node->type == SH_NODE_TEX_IMAGE) { + NodeTexImage *tex = (NodeTexImage *)node->storage; + tex->iuser.ok = 1; + tex->iuser.scene = NULL; + } + else if (node->type == SH_NODE_TEX_ENVIRONMENT) { + NodeTexEnvironment *tex = (NodeTexEnvironment *)node->storage; + tex->iuser.ok = 1; + tex->iuser.scene = NULL; + } } else if (ntree->type == NTREE_COMPOSIT) { if (ELEM(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT)) @@ -3331,10 +3341,14 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) } } else if (ntree->type == NTREE_TEXTURE) { - if (node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME) + if (node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME) { direct_link_curvemapping(fd, node->storage); - else if (node->type == TEX_NODE_IMAGE) - ((ImageUser *)node->storage)->ok = 1; + } + else if (node->type == TEX_NODE_IMAGE) { + ImageUser *iuser = node->storage; + iuser->ok = 1; + iuser->scene = NULL; + } } } } @@ -3658,6 +3672,7 @@ static void direct_link_camera(FileData *fd, Camera *ca) for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) { bgpic->iuser.ok = 1; + bgpic->iuser.scene = NULL; } } @@ -4126,6 +4141,7 @@ static void direct_link_texture(FileData *fd, Tex *tex) tex->preview = direct_link_preview_image(fd, tex->preview); tex->iuser.ok = 1; + tex->iuser.scene = NULL; } diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 560b7330603..8db93ae3bba 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -480,8 +480,6 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, Camera *cam = v3d->camera->data; for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) { - bgpic->iuser.scene = scene; /* Needed for render results. */ - if ((bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != fg_flag) continue; @@ -504,13 +502,16 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, ima = bgpic->ima; if (ima == NULL) continue; - BKE_image_user_frame_calc(&bgpic->iuser, (int)DEG_get_ctime(depsgraph)); - if (ima->source == IMA_SRC_SEQUENCE && !(bgpic->iuser.flag & IMA_USER_FRAME_IN_RANGE)) { + + ImageUser iuser = bgpic->iuser; + iuser.scene = scene; /* Needed for render results. */ + BKE_image_user_frame_calc(&iuser, (int)DEG_get_ctime(depsgraph)); + if (ima->source == IMA_SRC_SEQUENCE && !(iuser.flag & IMA_USER_FRAME_IN_RANGE)) { ibuf = NULL; /* frame is out of range, dont show */ } else { - view3d_stereo_bgpic_setup(scene, v3d, ima, &bgpic->iuser); - ibuf = BKE_image_acquire_ibuf(ima, &bgpic->iuser, &lock); + view3d_stereo_bgpic_setup(scene, v3d, ima, &iuser); + ibuf = BKE_image_acquire_ibuf(ima, &iuser, &lock); releaseibuf = ibuf; } |