summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-04-23 15:18:16 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-04-23 20:52:53 +0200
commit1333600682019891efdb4acf51c4c1a9b7d3532d (patch)
tree1eebdd68bf72340b7a4803e5c8d1da273a8f9a13 /sc
parente3db0394655127102c3ba144e4de00ba73e83954 (diff)
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@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/navipi/content.cxx9
1 files changed, 9 insertions, 0 deletions
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");