Revision: 35685
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35685
Author:   campbellbarton
Date:     2011-03-22 08:30:07 +0000 (Tue, 22 Mar 2011)
Log Message:
-----------
fix for crashes moving armature layers and applying loc/scale/rot in armature 
editmode.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/object/object_transform.c

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c  2011-03-22 
08:21:16 UTC (rev 35684)
+++ trunk/blender/source/blender/editors/armature/poseobject.c  2011-03-22 
08:30:07 UTC (rev 35685)
@@ -1707,20 +1707,23 @@
 static int pose_armature_layers_exec (bContext *C, wmOperator *op)
 {
        Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
-       bArmature *arm= (ob)? ob->data : NULL;
        PointerRNA ptr;
        int layers[32]; /* hardcoded for now - we can only have 32 armature 
layers, so this should be fine... */
-       
+
+       if(ob==NULL || ob->data==NULL) {
+               return OPERATOR_CANCELLED;
+       }
+
        /* get the values set in the operator properties */
        RNA_boolean_get_array(op->ptr, "layers", layers);
-       
+
        /* get pointer for armature, and write data there... */
-       RNA_id_pointer_create((ID *)arm, &ptr);
+       RNA_id_pointer_create((ID *)ob->data, &ptr);
        RNA_boolean_set_array(&ptr, "layers", layers);
-       
+
        /* note, notifier might evolve */
        WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
-       
+
        return OPERATOR_FINISHED;
 }
 
@@ -1794,25 +1797,28 @@
 static int pose_bone_layers_exec (bContext *C, wmOperator *op)
 {
        Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
-       bArmature *arm= (ob)? ob->data : NULL;
        PointerRNA ptr;
        int layers[32]; /* hardcoded for now - we can only have 32 armature 
layers, so this should be fine... */
-       
+
+       if(ob==NULL || ob->data==NULL) {
+               return OPERATOR_CANCELLED;
+       }
+
        /* get the values set in the operator properties */
        RNA_boolean_get_array(op->ptr, "layers", layers);
-       
+
        /* set layers of pchans based on the values set in the operator props */
-       CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones) 
+       CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones)
        {
                /* get pointer for pchan, and write flags this way */
-               RNA_pointer_create((ID *)arm, &RNA_Bone, pchan->bone, &ptr);
+               RNA_pointer_create((ID *)ob->data, &RNA_Bone, pchan->bone, 
&ptr);
                RNA_boolean_set_array(&ptr, "layers", layers);
        }
        CTX_DATA_END;
-       
+
        /* note, notifier might evolve */
        WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
-       
+
        return OPERATOR_FINISHED;
 }
 

Modified: trunk/blender/source/blender/editors/object/object_transform.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_transform.c      
2011-03-22 08:21:16 UTC (rev 35684)
+++ trunk/blender/source/blender/editors/object/object_transform.c      
2011-03-22 08:30:07 UTC (rev 35685)
@@ -607,7 +607,7 @@
        
        /* api callbacks */
        ot->exec= location_apply_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode; /* editmode will crash */
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -627,7 +627,7 @@
        
        /* api callbacks */
        ot->exec= scale_apply_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -647,7 +647,7 @@
        
        /* api callbacks */
        ot->exec= rotation_apply_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to