From 8c49e6f99e412c5752f70f506b5554c283ad9dbc Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 3 May 2018 16:34:25 +0200 Subject: Multi-Object Pose: Fix POSE_OT_flip_names --- source/blender/editors/armature/pose_edit.c | 43 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index c1e9346efdd..4d29bef63ee 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -618,34 +618,31 @@ static void pose_copy_menu(Scene *scene) static int pose_flip_names_exec(bContext *C, wmOperator *op) { - Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm; - - /* paranoia checks */ - if (ELEM(NULL, ob, ob->pose)) - return OPERATOR_CANCELLED; - + ViewLayer *view_layer = CTX_data_view_layer(C); const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers"); - - arm = ob->data; - - ListBase bones_names = {NULL}; - - CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) + + FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob) { - BLI_addtail(&bones_names, BLI_genericNodeN(pchan->name)); - } - CTX_DATA_END; + bArmature *arm = ob->data; + ListBase bones_names = {NULL}; - ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers); + FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan) + { + BLI_addtail(&bones_names, BLI_genericNodeN(pchan->name)); + } + FOREACH_PCHAN_SELECTED_IN_OBJECT_END; - BLI_freelistN(&bones_names); - - /* since we renamed stuff... */ - DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers); - /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); + BLI_freelistN(&bones_names); + + /* since we renamed stuff... */ + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + + /* note, notifier might evolve */ + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); + } + FOREACH_OBJECT_IN_MODE_END; return OPERATOR_FINISHED; } -- cgit v1.2.3