Fix T64059: Crash in shader when using other object's texture space
Can not use evaluated datablock to localize since that could point to another evaluated datablock, which can not become part of another dependency graph. The original code needed to have unkeyed changes preserved, but now we do have a flush of animation to an active dependency graph, so this code is not needed anymore.
This commit is contained in:
parent
ae21dfc236
commit
51347be24e
Notes:
blender-bot
2023-02-14 07:17:43 +01:00
Referenced by issue #64059, ColorRamp node crash Referenced by issue #63747, Blender crashes at switching to Texture view
|
@ -331,28 +331,22 @@ static World *preview_get_localized_world(ShaderPreview *sp, World *world)
|
|||
return sp->worldcopy;
|
||||
}
|
||||
|
||||
static ID *duplicate_ids(ID *id, Depsgraph *depsgraph)
|
||||
static ID *duplicate_ids(ID *id)
|
||||
{
|
||||
if (id == NULL) {
|
||||
/* Non-ID preview render. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ID *id_eval = id;
|
||||
|
||||
if (depsgraph) {
|
||||
id_eval = DEG_get_evaluated_id(depsgraph, id);
|
||||
}
|
||||
|
||||
switch (GS(id->name)) {
|
||||
case ID_MA:
|
||||
return (ID *)BKE_material_localize((Material *)id_eval);
|
||||
return (ID *)BKE_material_localize((Material *)id);
|
||||
case ID_TE:
|
||||
return (ID *)BKE_texture_localize((Tex *)id_eval);
|
||||
return (ID *)BKE_texture_localize((Tex *)id);
|
||||
case ID_LA:
|
||||
return (ID *)BKE_light_localize((Light *)id_eval);
|
||||
return (ID *)BKE_light_localize((Light *)id);
|
||||
case ID_WO:
|
||||
return (ID *)BKE_world_localize((World *)id_eval);
|
||||
return (ID *)BKE_world_localize((World *)id);
|
||||
case ID_IM:
|
||||
case ID_BR:
|
||||
case ID_SCR:
|
||||
|
@ -820,11 +814,6 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
|
|||
char name[32];
|
||||
int sizex;
|
||||
Main *pr_main = sp->pr_main;
|
||||
ID *id_eval = id;
|
||||
|
||||
if (sp->depsgraph) {
|
||||
id_eval = DEG_get_evaluated_id(sp->depsgraph, id);
|
||||
}
|
||||
|
||||
/* in case of split preview, use border render */
|
||||
if (split) {
|
||||
|
@ -848,7 +837,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
|
|||
}
|
||||
|
||||
/* get the stuff from the builtin preview dbase */
|
||||
sce = preview_prepare_scene(sp->bmain, sp->scene, id_eval, idtype, sp);
|
||||
sce = preview_prepare_scene(sp->bmain, sp->scene, id, idtype, sp);
|
||||
if (sce == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -1327,7 +1316,7 @@ void ED_preview_icon_render(
|
|||
ip.scene = scene;
|
||||
ip.owner = BKE_previewimg_id_ensure(id);
|
||||
ip.id = id;
|
||||
ip.id_copy = duplicate_ids(id, NULL);
|
||||
ip.id_copy = duplicate_ids(id);
|
||||
|
||||
icon_preview_add_size(&ip, rect, sizex, sizey);
|
||||
|
||||
|
@ -1368,7 +1357,7 @@ void ED_preview_icon_job(
|
|||
ip->depsgraph = CTX_data_depsgraph(C);
|
||||
ip->owner = owner;
|
||||
ip->id = id;
|
||||
ip->id_copy = duplicate_ids(id, ip->depsgraph);
|
||||
ip->id_copy = duplicate_ids(id);
|
||||
|
||||
icon_preview_add_size(ip, rect, sizex, sizey);
|
||||
|
||||
|
@ -1434,7 +1423,7 @@ void ED_preview_shader_job(const bContext *C,
|
|||
sp->sizey = sizey;
|
||||
sp->pr_method = method;
|
||||
sp->id = id;
|
||||
sp->id_copy = duplicate_ids(id, sp->depsgraph);
|
||||
sp->id_copy = duplicate_ids(id);
|
||||
sp->own_id_copy = true;
|
||||
sp->parent = parent;
|
||||
sp->slot = slot;
|
||||
|
|
Loading…
Reference in New Issue