From 79e9440856fb0b8f05588a25ee70e7812ed702b9 Mon Sep 17 00:00:00 2001
From: Christoph Lendenfeld <chris.lenden@gmail.com>
Date: Thu, 5 Dec 2024 12:47:04 +0100
Subject: [PATCH] Fix #130061: Pose Sliding with no bones selected resets
 overlay flags

The issue was that the struct `tPoseSlideOp` tracks the
viewport overlay flags so they can be restored after the operator has run.
But the flag was stored at the end of `pose_slide_invoke_common` which
exits early if no keys are selected.
This then calls `pose_slide_exit` which sets the viewport flags to 0, because they were
never stored in the first place.

The fix is to move the storing of the flag up to `pose_slide_init` to ensure that it
is captured as soon as the struct is allocated.

Pull Request: https://projects.blender.org/blender/blender/pulls/131327
---
 source/blender/editors/armature/pose_slide.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 13b3c04b530..88eb6504823 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -277,6 +277,10 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode)
   pso->num.val_flag[0] |= NUM_NO_NEGATIVE;
   pso->num.unit_type[0] = B_UNIT_NONE; /* Percentages don't have any units. */
 
+  /* Save current bone visibility. */
+  View3D *v3d = pso->area->spacedata.first;
+  pso->overlay_flag = v3d->overlay.flag;
+
   /* Return status is whether we've got all the data we were requested to get. */
   return 1;
 }
@@ -1111,10 +1115,6 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, const wmEvent *
   /* Add a modal handler for this operator. */
   WM_event_add_modal_handler(C, op);
 
-  /* Save current bone visibility. */
-  View3D *v3d = pso->area->spacedata.first;
-  pso->overlay_flag = v3d->overlay.flag;
-
   return OPERATOR_RUNNING_MODAL;
 }
 
-- 
GitLab