[Libreoffice-commits] core.git: sc/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 23 18:53:31 UTC 2021


 sc/source/ui/navipi/content.cxx |    9 +++++++++
 1 file changed, 9 insertions(+)

New commits:
commit 1333600682019891efdb4acf51c4c1a9b7d3532d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Apr 23 15:18:16 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Apr 23 20:52:53 2021 +0200

    tdf#130326 clamp number of items in calc content tree
    
    if the number of items exceeds 1000, just stop, the UI
    becomes unresponsive.
    This takes the load time from 24s to 17s on my machine, and also
    makes clicking around much better (because it rebuilds the tree on
    every single cursor click)
    
    Change-Id: Ib32578306d1098fe9953d8c96b6926110c64d1c4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114553
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 2ede5b43cd36..03002a29272c 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -865,6 +865,8 @@ bool ScContentTree::IsPartOfType( ScContentId nContentType, sal_uInt16 nObjIdent
     return bRet;
 }
 
+constexpr int MAX_TREE_NODES = 1000;
+
 void ScContentTree::GetDrawNames( ScContentId nType )
 {
     if ( nRootType != ScContentId::ROOT && nRootType != nType )              // hidden ?
@@ -883,6 +885,7 @@ void ScContentTree::GetDrawNames( ScContentId nType )
         return;
 
     SCTAB nTabCount = pDoc->GetTableCount();
+    int treeNodeCount = 0;
     for (SCTAB nTab=0; nTab<nTabCount; nTab++)
     {
         SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
@@ -905,6 +908,12 @@ void ScContentTree::GetDrawNames( ScContentId nType )
                             {
                                 m_xTreeView->insert(pParent, -1, &aName, nullptr, nullptr, nullptr, false, m_xScratchIter.get());
                                 m_xTreeView->set_sensitive(*m_xScratchIter, true);
+                                treeNodeCount++;
+                                if (treeNodeCount > MAX_TREE_NODES)
+                                {
+                                    SAL_WARN("sc", "too many tree nodes, ignoring the rest");
+                                    return;
+                                }
                             }//end if parent
                             else
                                 SAL_WARN("sc", "InsertContent without parent");


More information about the Libreoffice-commits mailing list