sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx | 14 +++++++++++++- sc/source/ui/inc/AccessibleSpreadsheet.hxx | 3 +++ vcl/osx/a11ytablewrapper.mm | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-)
New commits: commit c8a8b8e3a03a02c7ee0b616eb728103fb7cefad0 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Jun 12 20:02:19 2023 +0200 Commit: Patrick Luby <plub...@neooffice.org> CommitDate: Wed Jun 14 16:04:51 2023 +0200 tdf#155376 weakly cache ScAccessibleCell the macOS accessibility framework repeatedly queries and enumerates all of the visible cells. Every time this happens we create a new set of ScAccessibleCell, which then live until the application shuts down, which then causes a very slow shutdown. So I fix the problem by caching the ScAccessibleCell so we return the same one for a given cell position. Of course, this begs the question of why the ScAccessibleCell objects are not dying when we create new ones, which means we have some kind of leak or lifecycle problem somewhere, but anyhow, this is a fairly simple and comprehensive fix. Change-Id: Id2765236ac4524f490a51b56268fb8038612fd43 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152932 Tested-by: Jenkins Reviewed-by: Patrick Luby <plub...@neooffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit f22cb3dfab413a2917cd810b8e1b8f644a016327) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153025 diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx index 38e9fb7b7fde..03b92c39b996 100644 --- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx +++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx @@ -913,7 +913,9 @@ rtl::Reference<ScAccessibleCell> ScAccessibleSpreadsheet::GetAccessibleCellAt(sa return m_pAccFormulaCell; } else + { return ScAccessibleCell::create(this, mpViewShell, aCellAddress, GetAccessibleIndexFormula(nRow, nColumn), meSplitPos, mpAccDoc); + } } else { @@ -924,7 +926,17 @@ rtl::Reference<ScAccessibleCell> ScAccessibleSpreadsheet::GetAccessibleCellAt(sa return mpAccCell; } else - return ScAccessibleCell::create(this, mpViewShell, aCellAddress, getAccessibleIndex(nRow, nColumn), meSplitPos, mpAccDoc); + { + rtl::Reference<ScAccessibleCell> xCell; + auto it = m_mapCells.find(aCellAddress); + if (it != m_mapCells.end()) + xCell = it->second.get(); + if (xCell) + return xCell; + xCell = ScAccessibleCell::create(this, mpViewShell, aCellAddress, getAccessibleIndex(nRow, nColumn), meSplitPos, mpAccDoc); + m_mapCells.insert(std::make_pair(aCellAddress, xCell)); + return xCell; + } } } diff --git a/sc/source/ui/inc/AccessibleSpreadsheet.hxx b/sc/source/ui/inc/AccessibleSpreadsheet.hxx index 78e735942270..cfe604c7d4d6 100644 --- a/sc/source/ui/inc/AccessibleSpreadsheet.hxx +++ b/sc/source/ui/inc/AccessibleSpreadsheet.hxx @@ -22,6 +22,7 @@ #include <sal/config.h> #include <rtl/ref.hxx> +#include <unotools/weakref.hxx> #include "AccessibleTableBase.hxx" #include "viewdata.hxx" @@ -267,6 +268,8 @@ private: OUString m_strCurCellValue; ScRangeList m_LastMarkedRanges; OUString m_strOldTabName; + std::map<ScAddress, unotools::WeakReference< ScAccessibleCell > > + m_mapCells; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/osx/a11ytablewrapper.mm b/vcl/osx/a11ytablewrapper.mm index 6f8775f0a4b5..1c155313c97f 100644 --- a/vcl/osx/a11ytablewrapper.mm +++ b/vcl/osx/a11ytablewrapper.mm @@ -19,7 +19,7 @@ #include <osx/a11yfactory.h> - +#include <sal/log.hxx> #include "a11ytablewrapper.h" using namespace ::com::sun::star::accessibility; @@ -79,6 +79,7 @@ using namespace ::com::sun::star::uno; sal_Int32 columnTopLeft = accessibleTable -> getAccessibleColumn ( idxTopLeft ); sal_Int32 rowBottomRight = accessibleTable -> getAccessibleRow ( idxBottomRight ); sal_Int32 columnBottomRight = accessibleTable -> getAccessibleColumn ( idxBottomRight ); + SAL_WARN("vcl", "creating " << ((rowBottomRight - rowTopLeft) * (columnBottomRight - columnTopLeft)) << " cells"); // create an array containing the visible cells for ( sal_Int32 rowCount = rowTopLeft; rowCount <= rowBottomRight; rowCount++ ) {