sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx |   12 ++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 27c44ebd3c93c2a37f50bfa7e42caa9ecf825cc9
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Nov 23 16:16:05 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Nov 23 20:45:47 2022 +0100

    Resolves: tdf#145491 make sure focused page is selected after undo/redo
    
    Change-Id: I269315556624c48373815640605a93c91a4c9819
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143184
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx 
b/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx
index 4f733dc5c9c6..8fb0493a0b98 100644
--- a/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx
@@ -121,11 +121,17 @@ void SelectionObserver::EndObservation()
     }
 
     aUpdateLock.Release();
-    bool bSuccess = 
mrSlideSorter.GetController().GetFocusManager().SetFocusedPageToCurrentPage();
+    FocusManager& rFocusManager = 
mrSlideSorter.GetController().GetFocusManager();
+    bool bSuccess = rFocusManager.SetFocusedPageToCurrentPage();
     // tdf#129346 nothing currently selected, select something, if possible
     // but (tdf#129346) only if setting focus to current page failed
-    if (!bSuccess && rSelector.GetPageCount() && 
rSelector.GetSelectedPageCount() == 0)
-        rSelector.SelectPage(0);
+    if (rSelector.GetPageCount() && rSelector.GetSelectedPageCount() == 0)
+    {
+        if (bSuccess)
+            rSelector.SelectPage(rFocusManager.GetFocusedPageDescriptor());
+        else
+            rSelector.SelectPage(0);
+    }
 }
 
 } // end of namespace ::sd::slidesorter::controller

Reply via email to