Fix T55244: Parenting object(s) to curve crashes blender

There is a chance parts of Blender call BKE_object_workob_calc_parent
with ob->parent objects that are outside the depsgraph.

This we can tackle later since these are corner cases anyways,
and this fix fixes all parenting operators in Blender.
This commit is contained in:
Dalai Felinto
2018-05-29 14:00:36 +02:00
parent 8b24f45e6b
commit bc54823376

View File

@@ -2168,28 +2168,37 @@ void BKE_object_where_is_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
}
/* for calculation of the inverse parent transform, only used for editor */
/**
* For calculation of the inverse parent transform, only used for editor.
*
* It assumes the object parent is already in the depsgraph.
* Otherwise, after changing ob->parent you need to call:
* DEG_relations_tag_update(bmain);
* BKE_scene_graph_update_tagged(depsgraph, bmain);
*/
void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *ob, Object *workob)
{
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_object_workob_clear(workob);
unit_m4(workob->obmat);
unit_m4(workob->parentinv);
unit_m4(workob->constinv);
workob->parent = ob->parent;
workob->trackflag = ob->trackflag;
workob->upflag = ob->upflag;
/* Since this is used while calculating parenting, at this moment ob_eval->parent is still NULL. */
workob->parent = DEG_get_evaluated_object(depsgraph, ob->parent);
workob->trackflag = ob_eval->trackflag;
workob->upflag = ob_eval->upflag;
workob->partype = ob->partype;
workob->par1 = ob->par1;
workob->par2 = ob->par2;
workob->par3 = ob->par3;
workob->partype = ob_eval->partype;
workob->par1 = ob_eval->par1;
workob->par2 = ob_eval->par2;
workob->par3 = ob_eval->par3;
workob->constraints.first = ob->constraints.first;
workob->constraints.last = ob->constraints.last;
workob->constraints = ob_eval->constraints;
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
BLI_strncpy(workob->parsubstr, ob_eval->parsubstr, sizeof(workob->parsubstr));
BKE_object_where_is_calc(depsgraph, scene, workob);
}