tested running the cheat-sheet, found a number of segfaults
authorCampbell Barton <ideasman42@gmail.com>
Mon, 21 Sep 2009 09:17:14 +0000 (09:17 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 21 Sep 2009 09:17:14 +0000 (09:17 +0000)
pressing escape in the outliner was also crashing (somehow it tried to exit the file selector)

source/blender/editors/space_buttons/buttons_ops.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_image/space_image.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/windowmanager/intern/wm_event_system.c

index 5466a06550bf150a9e058f3aedd7218a6a49d072..4387da1934143e9bda0d8c6e732ae6751a55cddd 100644 (file)
@@ -738,9 +738,9 @@ void PARTICLE_OT_target_move_down(wmOperatorType *ot)
 static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
 {
        ParticleSystemModifierData *psmd = psys_get_modifier(ob,psys);
-       ParticleData *pa = psys->particles;
-       PTCacheEdit *edit = psys->edit;
-       PTCacheEditPoint *point = edit ? edit->points : NULL;
+       ParticleData *pa;
+       PTCacheEdit *edit;
+       PTCacheEditPoint *point;
        PTCacheEditKey *ekey = NULL;
        HairKey *key;
        int i, k;
@@ -751,8 +751,11 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
 
        if(!psys->part || psys->part->type != PART_HAIR)
                return;
+       
+       edit = psys->edit;
+       point= edit ? edit->points : NULL;
 
-       for(i=0; i<psys->totpart; i++,pa++) {
+       for(i=0, pa=psys->particles; i<psys->totpart; i++,pa++) {
                if(point) {
                        ekey = point->keys;
                        point++;
@@ -820,9 +823,9 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
 static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
 {
        ParticleSystemModifierData *psmd = psys_get_modifier(ob,psys);
-       ParticleData *pa = psys->particles;
-       PTCacheEdit *edit = psys->edit;
-       PTCacheEditPoint *point = edit ? edit->points : NULL;
+       ParticleData *pa;
+       PTCacheEdit *edit;
+       PTCacheEditPoint *point;
        PTCacheEditKey *ekey;
        HairKey *key;
        BVHTreeFromMesh bvhtree;
@@ -836,7 +839,10 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
 
        if(!psys || !psys->part || psys->part->type != PART_HAIR)
                return;
-
+       
+       edit= psys->edit;
+       point=  edit ? edit->points : NULL;
+       
        if(psmd->dm->deformedOnly)
                dm= psmd->dm;
        else
@@ -852,7 +858,7 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
 
        bvhtree_from_mesh_faces(&bvhtree, dm, 0.0, 2, 6);
 
-       for(i=0; i<psys->totpart; i++,pa++) {
+       for(i=0, pa= psys->particles; i<psys->totpart; i++,pa++) {
                key = pa->hair;
 
                nearest.index = -1;
index 70d8de7d5090938b22e6b9b62057cc4f34b7a95c..7839cf5bf4bd906bd754e8f70a57a678ba342426 100644 (file)
@@ -532,7 +532,7 @@ int file_operator_poll(bContext *C)
        int poll = ED_operator_file_active(C);
        SpaceFile *sfile= CTX_wm_space_file(C);
 
-       if (!sfile->op) poll= 0;
+       if (!sfile || !sfile->op) poll= 0;
 
        return poll;
 }
index f222499ba86778ea9cb8bb1bb769a75b9f492c42..f041cb00ee4de6bef15072980d27da711edb22de 100644 (file)
@@ -623,7 +623,7 @@ ImBuf *ED_space_image_buffer(SpaceImage *sima)
 {
        ImBuf *ibuf;
 
-       if(sima->image) {
+       if(sima && sima->image) {
 #if 0
                if(sima->image->type==IMA_TYPE_R_RESULT && BIF_show_render_spare())
                        return BIF_render_spare_imbuf();
index e59ec3746e36071ee64075132845eeb27b903ac4..64151918a47971983c33ecbab6fb529d43306edc 100644 (file)
@@ -4262,7 +4262,7 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *
 /* it deselects Bases, so we have to call the clear function always after */
 static void set_trans_object_base_flags(bContext *C, TransInfo *t)
 {
-       Scene *sce = CTX_data_scene(C);
+       Scene *scene = CTX_data_scene(C);
        View3D *v3d = t->view;
 
        /*
@@ -4279,15 +4279,15 @@ static void set_trans_object_base_flags(bContext *C, TransInfo *t)
        copy_baseflags(t->scene);
 
        /* handle pending update events, otherwise they got copied below */
-       for (base= sce->base.first; base; base= base->next) {
+       for (base= scene->base.first; base; base= base->next) {
                if(base->object->recalc)
                        object_handle_update(t->scene, base->object);
        }
 
-       for (base= sce->base.first; base; base= base->next) {
+       for (base= scene->base.first; base; base= base->next) {
                base->flag &= ~BA_WAS_SEL;
 
-               if(TESTBASELIB(v3d, base)) {
+               if(TESTBASELIB_BGMODE(v3d, base)) {
                        Object *ob= base->object;
                        Object *parsel= ob->parent;
 
@@ -4319,7 +4319,7 @@ static void set_trans_object_base_flags(bContext *C, TransInfo *t)
 
        /* and we store them temporal in base (only used for transform code) */
        /* this because after doing updates, the object->recalc is cleared */
-       for (base= sce->base.first; base; base= base->next) {
+       for (base= scene->base.first; base; base= base->next) {
                if(base->object->recalc & OB_RECALC_OB)
                        base->flag |= BA_HAS_RECALC_OB;
                if(base->object->recalc & OB_RECALC_DATA)
@@ -5319,7 +5319,7 @@ void createTransData(bContext *C, TransInfo *t)
                {
                        View3D *v3d = t->view;
                        RegionView3D *rv3d = CTX_wm_region_view3d(C);
-                       if((t->flag & T_OBJECT) && v3d->camera == OBACT && rv3d->persp==V3D_CAMOB)
+                       if(rv3d && (t->flag & T_OBJECT) && v3d->camera == OBACT && rv3d->persp==V3D_CAMOB)
                        {
                                t->flag |= T_CAMERA;
                        }
index 9416425704fa53102cd947abf2119e26305d59fd..d82be842596a1666d97df058cf4b455f52aa706e 100644 (file)
@@ -353,7 +353,8 @@ void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target) {
 
 void BIF_selectTransformOrientationValue(bContext *C, int orientation) {
        View3D *v3d = CTX_wm_view3d(C);
-       v3d->twmode = orientation;
+       if(v3d) /* currently using generic poll */
+               v3d->twmode = orientation;
 }
 
 EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
index 611eee00d79760e26cdde5bd46b5e8553666f28e..5597c624e23e759b65217c73cd97d8070dcf14a0 100644 (file)
@@ -1439,7 +1439,7 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
        else {
                sync= 0;
                selectmode= ts->uv_selectmode;
-               sticky= sima->sticky;
+               sticky= sima ? sima->sticky : 1;
        }
 
        /* find nearest element */
@@ -2471,13 +2471,18 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
 static int snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit)
 {
        EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data);
-       Image *ima= sima->image;
+       Image *ima;
        EditFace *efa;
        MTFace *tface;
        int width= 0, height= 0;
        float w, h;
        short change = 0;
 
+       if(!sima)
+               return 0;
+       
+       ima= sima->image;
+       
        ED_space_image_size(sima, &width, &height);
        w = (float)width;
        h = (float)height;
@@ -2657,6 +2662,7 @@ static int hide_exec(bContext *C, wmOperator *op)
        EditFace *efa;
        MTFace *tf;
        int swap= RNA_boolean_get(op->ptr, "unselected");
+       int facemode= sima ? sima->flag & SI_SELACTFACE : 0;
 
        if(ts->uv_flag & UV_SYNC_SELECTION) {
                EM_hide_mesh(em, swap);
@@ -2670,7 +2676,7 @@ static int hide_exec(bContext *C, wmOperator *op)
                for(efa= em->faces.first; efa; efa= efa->next) {
                        if(efa->f & SELECT) {
                                tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-                               if(sima->flag & SI_SELACTFACE) {
+                               if(facemode) {
                                        /* Pretend face mode */
                                        if((    (efa->v4==NULL && 
                                                        (       tf->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) ==                        (TF_SEL1|TF_SEL2|TF_SEL3) )                      ||
@@ -2715,7 +2721,7 @@ static int hide_exec(bContext *C, wmOperator *op)
                        if(efa->f & SELECT) {
                                tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
 
-                               if(sima->flag & SI_SELACTFACE) {
+                               if(facemode) {
                                        if(     (efa->v4==NULL && 
                                                        (       tf->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) ==                        (TF_SEL1|TF_SEL2|TF_SEL3) )                      ||
                                                        (       tf->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)) ==        (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)       ) {
@@ -2799,6 +2805,8 @@ static int reveal_exec(bContext *C, wmOperator *op)
        EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
+       int facemode= sima ? sima->flag & SI_SELACTFACE : 0;
+       int stickymode= sima ? (sima->sticky != SI_STICKY_DISABLE) : 1;
        
        /* call the mesh function if we are in mesh sync sel */
        if(ts->uv_flag & UV_SYNC_SELECTION) {
@@ -2809,7 +2817,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
                return OPERATOR_FINISHED;
        }
        
-       if(sima->flag & SI_SELACTFACE) {
+       if(facemode) {
                if(em->selectmode == SCE_SELECT_FACE) {
                        for(efa= em->faces.first; efa; efa= efa->next) {
                                if(!(efa->h) && !(efa->f & SELECT)) {
@@ -2821,7 +2829,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
                }
                else {
                        /* enable adjacent faces to have disconnected UV selections if sticky is disabled */
-                       if(sima->sticky == SI_STICKY_DISABLE) {
+                       if(!stickymode) {
                                for(efa= em->faces.first; efa; efa= efa->next) {
                                        if(!(efa->h) && !(efa->f & SELECT)) {
                                                /* All verts must be unselected for the face to be selected in the UV view */
index ebb7adc3cd51ed869f237223d81df6e6aa15ea72..6b07e384f661681853e92decef0d0a12b9fe123b 100644 (file)
@@ -1231,7 +1231,7 @@ void wm_event_do_handlers(bContext *C)
 
                                /* XXX hrmf, this gives reliable previous mouse coord for area change, feels bad? 
                                   doing it on ghost queue gives errors when mousemoves go over area borders */
-                               if(doit && win->screen->subwinactive != win->screen->mainwin) {
+                               if(doit && win->screen && win->screen->subwinactive != win->screen->mainwin) {
                                        win->eventstate->prevx= event->x;
                                        win->eventstate->prevy= event->y;
                                }
@@ -1244,7 +1244,7 @@ void wm_event_do_handlers(bContext *C)
                }
                
                /* only add mousemove when queue was read entirely */
-               if(win->addmousemove) {
+               if(win->addmousemove && win->eventstate) {
                        wmEvent event= *(win->eventstate);
                        event.type= MOUSEMOVE;
                        event.prevx= event.x;