diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2010-05-27 18:00:32 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2010-05-27 18:00:32 +0400 |
commit | 717701ed0f785f6452c37f412f43e08382694bc2 (patch) | |
tree | 401750f64e0b62246ed17416f0038893485c71ed | |
parent | 8f8c59903d30681088f29ffd82d5e80ab06e0c8d (diff) |
Fix #22422: Adding a new shape key with unchecked 'Relative' checkbox crashes blender
Reorder callning of add_keyblock and do_ob_key in insert_*key.
do_ob_key shouldn't be called for object with uninitialized key blocks.
NOTE: this commit not fixing problems with slurph
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 24c23e5ea41..576b3481d07 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2879,15 +2879,18 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, char *name, int from_m newkey= 1; } - kb= add_keyblock(key, name); - if(newkey || from_mix==FALSE) { /* create from mesh */ + kb= add_keyblock(key, name); mesh_to_key(me, kb); } else { /* copy from current values */ - kb->data= do_ob_key(scene, ob); + float *data= do_ob_key(scene, ob); + + /* create new block with prepared data */ + kb= add_keyblock(key, name); + kb->data= data; kb->totelem= me->totvert; } @@ -2907,16 +2910,20 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, char *name, int from_m newkey= 1; } - kb= add_keyblock(key, name); - if(newkey || from_mix==FALSE) { + kb= add_keyblock(key, name); + /* create from lattice */ latt_to_key(lt, kb); } else { /* copy from current values */ + float *data= do_ob_key(scene, ob); + + /* create new block with prepared data */ + kb= add_keyblock(key, name); kb->totelem= lt->pntsu*lt->pntsv*lt->pntsw; - kb->data= do_ob_key(scene, ob); + kb->data= data; } return kb; @@ -2936,16 +2943,19 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_ newkey= 1; } - kb= add_keyblock(key, name); - if(newkey || from_mix==FALSE) { /* create from curve */ + kb= add_keyblock(key, name); curve_to_key(cu, kb, lb); } else { /* copy from current values */ + float *data= do_ob_key(scene, ob); + + /* create new block with prepared data */ + kb= add_keyblock(key, name); kb->totelem= count_curveverts(lb); - kb->data= do_ob_key(scene, ob); + kb->data= data; } return kb; |