sfx2/source/control/bindings.cxx |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

New commits:
commit fb7b0b944741e4efae8d92a6e305036aff906c7a
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Jan 8 16:25:44 2024 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jan 9 07:08:55 2024 +0100

    cool#7492 sfx2 lok: just set language/locale on async binding update
    
    Trying to run online.git tests against commit
    51d8a2ef54751403fa707816e27ddb4e7faa8231 (cool#7492 sfx2 lok: fix bad
    view id / statusbar string on async binding update, 2024-01-08),
    unit-tiletest failed.
    
    Manually trying to replace what the
    testSimultaneousTilesRenderedJustOnce test in that suite tries to do, it
    turned out that it can happen that the bindings are updated when a
    Writer view gets its focus, which is a problem, because the above commit
    started to switch views on binding updates, leading to a loop (bindings
    are updated about every second).
    
    Fix the problem by doing less work in SfxBindings::NextJob(): it's
    enough if the timer just switches languages and not views. That still
    keeps the Calc statusbar problem fixed from the above commit, but avoids
    the problematic view switching that broke unit-tiletest.
    
    Change-Id: I22cd9b3276c3f9987a2d90ad93f6026fdf6b8448
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161792
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 95823f8bde4d..8eb8f2f78689 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -1215,26 +1215,28 @@ void SfxBindings::UpdateControllers_Impl
 IMPL_LINK( SfxBindings, NextJob, Timer *, pTimer, void )
 {
     bool bSetView = false;
-    int nOldId = -1;
+    SfxViewShell* pOldShell = nullptr;
     if (comphelper::LibreOfficeKit::isActive() && pDispatcher)
     {
         SfxViewFrame* pFrame = pDispatcher->GetFrame();
-        SfxViewShell* pShell = pFrame ? pFrame->GetViewShell() : nullptr;
-        int nNewId = SfxLokHelper::getView(pShell);
-        nOldId = SfxLokHelper::getView();
-        if (nNewId != -1 && nNewId != nOldId)
+        SfxViewShell* pNewShell = pFrame ? pFrame->GetViewShell() : nullptr;
+        pOldShell = SfxViewShell::Current();
+        if (pNewShell && pNewShell != pOldShell)
         {
-            // The current view ID is not the one that belongs to this frame, 
switch to it.
-            SfxLokHelper::setView(nNewId);
+            // The current view ID is not the one that belongs to this frame, 
update
+            // language/locale.
+            
comphelper::LibreOfficeKit::setLanguageTag(pNewShell->GetLOKLanguageTag());
+            comphelper::LibreOfficeKit::setLocale(pNewShell->GetLOKLocale());
             bSetView = true;
         }
     }
 
     NextJob_Impl(pTimer);
 
-    if (bSetView)
+    if (bSetView && pOldShell)
     {
-        SfxLokHelper::setView(nOldId);
+        
comphelper::LibreOfficeKit::setLanguageTag(pOldShell->GetLOKLanguageTag());
+        comphelper::LibreOfficeKit::setLocale(pOldShell->GetLOKLocale());
     }
 }
 

Reply via email to