From 4975aa410cf0178fa19a29256659f91d7ea84ccb Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Tue, 27 Oct 2020 15:10:44 +0100 Subject: Fix T81844: Change Bone Layers fails in Pose Mode When selecting multiple layers, the redo operator might not correctly update the pose data. To make sure it is in a good state we have to ensure that the pose data is good. Reviewed By: Bastien Differential Revision: http://developer.blender.org/D9354 --- source/blender/editors/armature/pose_edit.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/editors/armature') diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index e8c35958115..8a1c2a4afa8 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -898,6 +898,20 @@ static int pose_bone_layers_exec(bContext *C, wmOperator *op) Object *prev_ob = NULL; + /* Make sure that the pose bone data is up to date. + * (May not always be the case after undo/redo e.g.). + */ + struct Main *bmain = CTX_data_main(C); + wmWindow *win = CTX_wm_window(C); + View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */ + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + + FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) { + bArmature *arm = ob_iter->data; + BKE_pose_ensure(bmain, ob_iter, arm, true); + } + FOREACH_OBJECT_IN_MODE_END; + /* set layers of pchans based on the values set in the operator props */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) { /* get pointer for pchan, and write flags this way */ -- cgit v1.2.3