sd/source/ui/animations/SlideTransitionPane.cxx |    6 +++++-
 sd/source/ui/inc/SlideTransitionPane.hxx        |    2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 7424f63fc605aff917d9d65ddc8e0e22a13d99bd
Author:     Rashesh Padia <rashesh.pa...@collabora.com>
AuthorDate: Sun Sep 21 19:09:08 2025 +0530
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Mon Sep 22 06:22:38 2025 +0200

    tdf#167753: Fix infinite recursion in SlideTransitionPane focus handling
    
    Add recursion guard to applyToSelectedPages() to prevent infinite loop
    between VariantListBoxSelected and DurationLoseFocusHdl handlers.
    
    Problem:
    1. User selects variant -> VariantListBoxSelected ->
    applyToSelectedPages()
    2. Focus restoration via pFocusWindow->GrabFocus() at function end
    3. Duration field somehow loses focus -> DurationLoseFocusHdl triggered
    4. Calls applyToSelectedPages() again -> infinite recursion
    
    Focus restoration creates unguarded recursive pathway.
    The exact mechanism of why focus restoration causes duration field to
    lose focus is unknown.
    
    This patch fixes the problem by adding mbInApplyToPages guard to prevent
    re-entry into
    applyToSelectedPages() regardless of the underlying focus behavior.
    
    Change-Id: I3356f9f3c0a1bcff5ac04e961f2cca48785d8538
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191293
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/sd/source/ui/animations/SlideTransitionPane.cxx 
b/sd/source/ui/animations/SlideTransitionPane.cxx
index d5fef0f84362..18406a062a83 100644
--- a/sd/source/ui/animations/SlideTransitionPane.cxx
+++ b/sd/source/ui/animations/SlideTransitionPane.cxx
@@ -882,9 +882,11 @@ impl::TransitionEffect 
SlideTransitionPane::getTransitionEffectFromControls() co
 
 void SlideTransitionPane::applyToSelectedPages(bool bPreview = true)
 {
-    if(  mbUpdatingControls )
+    if (mbUpdatingControls || mbInApplyToPages)
         return;
 
+    mbInApplyToPages = true;
+
     vcl::Window *pFocusWindow = Application::GetFocusWindow();
 
     ::sd::slidesorter::SharedPageSelection pSelectedPages( getSelectedPages());
@@ -906,6 +908,8 @@ void SlideTransitionPane::applyToSelectedPages(bool 
bPreview = true)
 
     if (pFocusWindow)
         pFocusWindow->GrabFocus();
+
+    mbInApplyToPages = false;
 }
 
 void SlideTransitionPane::playCurrentEffect()
diff --git a/sd/source/ui/inc/SlideTransitionPane.hxx 
b/sd/source/ui/inc/SlideTransitionPane.hxx
index b7354025f6b9..fe078634f6ec 100644
--- a/sd/source/ui/inc/SlideTransitionPane.hxx
+++ b/sd/source/ui/inc/SlideTransitionPane.hxx
@@ -145,6 +145,8 @@ private:
     mutable OUString maCurrentSoundFile;
 
     Timer maLateInitTimer;
+
+    bool mbInApplyToPages = false;
 };
 
 } //  namespace sd

Reply via email to