sw/source/uibase/inc/conttree.hxx  |    2 +-
 sw/source/uibase/utlui/content.cxx |   20 ++++++++++++--------
 2 files changed, 13 insertions(+), 9 deletions(-)

New commits:
commit 61bc7ce2aa02eb621de8e4c879646767af3d28ce
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Wed Apr 30 13:52:09 2025 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Tue May 6 12:13:51 2025 +0200

    Navigator: freeze/thaw collapse
    
    Do single set of freeze / thaw.
    Previously we did once for cleanup, then
    another one for fill. That is worse for JSDialog
    where thaw emits update of the widget.
    
    expand_row has assertion protecting from doing it in the
    frozen state.
    
    Change-Id: I1b962560b5f864cca42c475789917a2ce5e61bb6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184835
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/source/uibase/inc/conttree.hxx 
b/sw/source/uibase/inc/conttree.hxx
index 4a732f4e56ca..362a334dffe1 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -236,7 +236,7 @@ public:
     /** Show the file */
     void            Display( bool bActiveView );
     /** In the clear the content types have to be deleted, also. */
-    void            clear();
+    void            clear(bool bLeaveFrozen = false);
 
     /** After a file is dropped on the Navigator, the new shell will be set */
     void            SetHiddenShell(SwWrtShell* pSh);
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 06a0b2f9ce9d..2eee844b520f 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -3044,7 +3044,10 @@ void SwContentTree::Display( bool bActive )
             nEntryRelPos = GetAbsPos(*xOldSelEntry) - GetAbsPos(*xParentEntry);
     }
 
-    clear();
+    SwWrtShell* pShell = GetWrtShell();
+    // thaw updates widget, in case we still do modification - leave it frozen
+    bool bLeaveFrozen = !!pShell;
+    clear(bLeaveFrozen);
 
     if (!bActive)
     {
@@ -3059,7 +3062,6 @@ void SwContentTree::Display( bool bActive )
     else if (State::HIDDEN == m_eState)
         m_eState = State::ACTIVE;
 
-    SwWrtShell* pShell = GetWrtShell();
     if (pShell)
     {
         std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator();
@@ -3068,8 +3070,6 @@ void SwContentTree::Display( bool bActive )
         // all content navigation view
         if(m_nRootType == ContentTypeId::UNKNOWN)
         {
-            m_xTreeView->freeze();
-
             for( ContentTypeId nCntType : o3tl::enumrange<ContentTypeId>() )
             {
                 std::unique_ptr<SwContentType>& rpContentT = bActive ?
@@ -3107,6 +3107,7 @@ void SwContentTree::Display( bool bActive )
                 }
             }
 
+            bLeaveFrozen = false; // do not thaw on the end
             m_xTreeView->thaw();
 
             // restore visual expanded tree state
@@ -3116,8 +3117,6 @@ void SwContentTree::Display( bool bActive )
         // root content navigation view
         else
         {
-            m_xTreeView->freeze();
-
             std::unique_ptr<SwContentType>& rpRootContentT = bActive ?
                                     m_aActiveContentArr[m_nRootType] :
                                     m_aHiddenContentArr[m_nRootType];
@@ -3144,6 +3143,7 @@ void SwContentTree::Display( bool bActive )
 
             m_xTreeView->set_sensitive(*xEntry, 
m_xTreeView->iter_has_child(*xEntry));
 
+            bLeaveFrozen = false; // do not thaw on the end
             m_xTreeView->thaw();
 
             if (bChOnDemand)
@@ -3188,18 +3188,22 @@ void SwContentTree::Display( bool bActive )
         UpdateContentFunctionsToolbar();
     }
 
+    if (bLeaveFrozen)
+        m_xTreeView->thaw();
+
     if (!m_bIgnoreDocChange && GetEntryCount() == nOldEntryCount)
     {
         m_xTreeView->vadjustment_set_value(nOldScrollPos);
     }
 }
 
-void SwContentTree::clear()
+void SwContentTree::clear(bool bLeaveFrozen)
 {
     m_xTreeView->freeze();
     m_xTreeView->clear();
     m_nEntryCount = 0;
-    m_xTreeView->thaw();
+    if (!bLeaveFrozen)
+        m_xTreeView->thaw();
 }
 
 bool SwContentTree::FillTransferData(TransferDataContainer& rTransfer)

Reply via email to