From 98527a71061735a20b712a2c4d552c0c966e5798 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Oct 2009 18:49:36 +0000 Subject: [PATCH] various small fixes - undo stops all running jobs (operator redo was crashing with threaded render) - adding new armatures was crashing if there was no valid view3d - transform with an active hidden object would crash --- source/blender/blenkernel/intern/blender.c | 3 +++ source/blender/editors/armature/editarmature.c | 6 +++--- source/blender/editors/curve/editcurve.c | 2 +- source/blender/editors/metaball/mball_edit.c | 2 +- .../blender/editors/transform/transform_orientations.c | 10 ++++++++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 94b03730e54..a387d1bca9d 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -536,6 +536,9 @@ static int read_undosave(bContext *C, UndoElem *uel) char scestr[FILE_MAXDIR+FILE_MAXFILE]; int success=0, fileflags; + /* This is needed so undoing/redoing doesnt crash with threaded previews going */ + WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C)); + strcpy(scestr, G.sce); /* temporal store */ fileflags= G.fileflags; G.fileflags |= G_FILE_NO_UI; diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 1e94e1b440c..c5b01f1cab0 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -2242,7 +2242,7 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) VECCOPY(bone->head, curs); - if ( (U.flag & USER_ADD_VIEWALIGNED) ) + if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) VecAddf(bone->tail, bone->head, imat[1]); // bone with unit length 1 else VecAddf(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z @@ -3423,7 +3423,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) Mat4Invert(obedit->imat, obedit->obmat); Mat4MulVecfl(obedit->imat, curs); - if (U.flag & USER_ADD_VIEWALIGNED) + if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) Mat3CpyMat4(obmat, rv3d->viewmat); else Mat3One(obmat); @@ -3438,7 +3438,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) VECCOPY(bone->head, curs); - if(U.flag & USER_ADD_VIEWALIGNED) + if(rv3d && (U.flag & USER_ADD_VIEWALIGNED)) VecAddf(bone->tail, bone->head, imat[1]); // bone with unit length 1 else VecAddf(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 45820869b48..a58439051e9 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4729,7 +4729,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) cent[2]-= obedit->obmat[3][2]; if(rv3d) { - if (!newname && U.flag & USER_ADD_VIEWALIGNED) + if (!newname && (U.flag & USER_ADD_VIEWALIGNED)) Mat3CpyMat4(imat, rv3d->viewmat); else Mat3One(imat); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 6ad7fbabfcb..f335e47188f 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -129,7 +129,7 @@ MetaElem *add_metaball_primitive(bContext *C, int type, int newname) cent[2]-= obedit->obmat[3][2]; if (rv3d) { - if (!(newname) || U.flag & USER_ADD_VIEWALIGNED || !rv3d) + if (!(newname) || U.flag & USER_ADD_VIEWALIGNED) Mat3CpyMat4(imat, rv3d->viewmat); else Mat3One(imat); diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index e790b38dd67..933d3303437 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -518,6 +518,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) Object *obedit = CTX_data_active_object(C); float normal[3]={0.0, 0.0, 0.0}; float plane[3]={0.0, 0.0, 0.0}; + switch(t->current_orientation) { case V3D_MANIP_GLOBAL: @@ -530,7 +531,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) gimbalAxis(ob, t->spacemtx); break; case V3D_MANIP_NORMAL: - if(obedit || ob->mode & OB_MODE_POSE) { + if(obedit || (ob && ob->mode & OB_MODE_POSE)) { float mat[3][3]; int type; @@ -579,7 +580,12 @@ void initTransformOrientation(bContext *C, TransInfo *t) /* no break we define 'normal' as 'local' in Object mode */ case V3D_MANIP_LOCAL: strcpy(t->spacename, "local"); - Mat3CpyMat4(t->spacemtx, ob->obmat); + + if(ob) + Mat3CpyMat4(t->spacemtx, ob->obmat); + else + Mat3One(t->spacemtx); + Mat3Ortho(t->spacemtx); break;