Fix T49168: crash when evaluating a cache constraint with a NULL cache

file.
This commit is contained in:
Kévin Dietrich 2016-08-26 14:21:06 +02:00
parent 1ada3231ec
commit f2f107572c

@ -4353,11 +4353,15 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
bTransformCacheConstraint *data = con->data;
Scene *scene = cob->scene;
const float frame = BKE_scene_frame_get(scene);
const float time = BKE_cachefile_time_offset(data->cache_file, frame, FPS);
CacheFile *cache_file = data->cache_file;
if (!cache_file) {
return;
}
const float frame = BKE_scene_frame_get(scene);
const float time = BKE_cachefile_time_offset(cache_file, frame, FPS);
BKE_cachefile_ensure_handle(G.main, cache_file);
ABC_get_transform(cache_file->handle, cob->ob, data->object_path,
@ -4391,6 +4395,13 @@ static void transformcache_free(bConstraint *con)
}
}
static void transformcache_new_data(void *cdata)
{
bTransformCacheConstraint *data = (bTransformCacheConstraint *)cdata;
data->cache_file = NULL;
}
static bConstraintTypeInfo CTI_TRANSFORM_CACHE = {
CONSTRAINT_TYPE_TRANSFORM_CACHE, /* type */
sizeof(bTransformCacheConstraint), /* size */
@ -4399,7 +4410,7 @@ static bConstraintTypeInfo CTI_TRANSFORM_CACHE = {
transformcache_free, /* free data */
transformcache_id_looper, /* id looper */
transformcache_copy, /* copy data */
NULL, /* new data */
transformcache_new_data, /* new data */
NULL, /* get constraint targets */
NULL, /* flush constraint targets */
NULL, /* get target matrix */