crash fix for Normalize All VGroups on a lattice without vgroups (probably other...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 22 Mar 2011 10:13:42 +0000 (10:13 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 22 Mar 2011 10:13:42 +0000 (10:13 +0000)
Also fix for crashes running operators in bg mode by using setting poll functions: WM_OT_search_menu, MESH_OT_extrude_repeat, SCREEN_OT_new

source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/screen/screen_ops.c
source/blender/windowmanager/intern/wm_operators.c

index b437882..68a76f5 100644 (file)
@@ -944,7 +944,7 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec= extrude_repeat_mesh;
-       ot->poll= ED_operator_editmesh;
+       ot->poll= ED_operator_editmesh_region_view3d;
 
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
index af18a70..f1692c1 100644 (file)
@@ -208,14 +208,19 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to
                                Lattice *lt= (Lattice *)id;
                                lt= (lt->editlatt)? lt->editlatt->latt: lt;
 
-                               *dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw;
-                               *dvert_arr= MEM_mallocN(sizeof(void*)*(*dvert_tot), "vgroup parray from me");
+                               if(lt->dvert) {
+                                       *dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw;
+                                       *dvert_arr= MEM_mallocN(sizeof(void*)*(*dvert_tot), "vgroup parray from me");
 
-                               for (i=0; i<*dvert_tot; i++) {
-                                       (*dvert_arr)[i] = lt->dvert + i;
-                               }
+                                       for (i=0; i<*dvert_tot; i++) {
+                                               (*dvert_arr)[i] = lt->dvert + i;
+                                       }
 
-                               return 1;
+                                       return 1;
+                               }
+                               else {
+                                       return 0;
+                               }
                        }
                }
        }
index 72cc4a4..5236d67 100644 (file)
@@ -3111,6 +3111,7 @@ static void SCREEN_OT_new(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= screen_new_exec;
+       ot->poll= WM_operator_winactive;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
index 74c2045..8aa89f6 100644 (file)
@@ -1320,6 +1320,7 @@ static void WM_OT_call_menu(wmOperatorType *ot)
        ot->idname= "WM_OT_call_menu";
 
        ot->exec= wm_call_menu_exec;
+       ot->poll= WM_operator_winactive;
 
        RNA_def_string(ot->srna, "name", "", BKE_ST_MAXNAME, "Name", "Name of the menu");
 }