various small fixes
authorCampbell Barton <ideasman42@gmail.com>
Thu, 29 Oct 2009 18:49:36 +0000 (18:49 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 29 Oct 2009 18:49:36 +0000 (18:49 +0000)
- 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
source/blender/editors/armature/editarmature.c
source/blender/editors/curve/editcurve.c
source/blender/editors/metaball/mball_edit.c
source/blender/editors/transform/transform_orientations.c

index 94b03730e54d055698fc700edae5fa7e94cb86d8..a387d1bca9df7cd0ee71cd1fbfe3b8b9dc2ff8e5 100644 (file)
@@ -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;
index 1e94e1b440c04c0a5c8b6df10cad5f1da28343b4..c5b01f1cab058beb5797c8f0f969a9dc91c390c6 100644 (file)
@@ -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
index 45820869b4815cf24f3926f114b3355e3e7fb3bc..a58439051e9685e621e929a79ded76fb102fd9fc 100644 (file)
@@ -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);
index 6ad7fbabfcb04f76a654c187d973c8c595377e9e..f335e47188f63f88666406312271ec8e9119106e 100644 (file)
@@ -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);
index e790b38dd679eb149820d0451bd9da9b54d1c439..933d330343761cace579607503a8198f016b6382 100644 (file)
@@ -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;