check for error that could happen when making editmode armatures
authorCampbell Barton <ideasman42@gmail.com>
Fri, 30 Oct 2009 13:08:58 +0000 (13:08 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 30 Oct 2009 13:08:58 +0000 (13:08 +0000)
source/blender/editors/object/object_add.c

index 9b7b23f10262d67679f6d2242d48a9ac6d901a7c..cbf08fbe705d3ce55b894930d62a3d999a77d583 100644 (file)
@@ -525,12 +525,18 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
        int newob= 0;
        
        if ((obedit==NULL) || (obedit->type != OB_ARMATURE)) {
-               ED_object_add_type(C, OB_ARMATURE);
+               obedit= ED_object_add_type(C, OB_ARMATURE);
                ED_object_enter_editmode(C, 0);
+               obedit= CTX_data_edit_object(C);
                newob = 1;
        }
        else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
        
+       if(obedit==NULL) {
+               BKE_report(op->reports, RPT_ERROR, "Cannot create editmode armature.");
+               return OPERATOR_CANCELLED;
+       }
+       
        if(v3d) 
                rv3d= CTX_wm_region(C)->regiondata;