summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-20 10:19:25 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-05-21 13:25:22 -0400
commit65d026f39cff52c96be95871e16a3d6714203d2e (patch)
tree604530ace5fc20f01efa4810f0f498de877e524e
parentc28aadc7fcb1858acc2e59a875e0a4c9071681ed (diff)
cp#1000072: Purge one document shell at a time, to avoid freeze.
Import especially when we have a whole bunch of large-ish documents open in the background. Change-Id: I614e6daab3481c09dae47c8407497d77aec40480
-rw-r--r--sc/source/core/data/documen8.cxx2
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx13
2 files changed, 8 insertions, 7 deletions
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 4563b02364c3..6b2f02822480 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -806,7 +806,7 @@ void ScDocument::UpdateExternalRefLinks(Window* pWin)
ScProgress aProgress(GetDocumentShell(), "Updating external links", aRefLinks.size());
for (size_t i = 0, n = aRefLinks.size(); i < n; ++i)
{
- aProgress.SetState(i);
+ aProgress.SetState(i+1);
ScExternalRefLink* pRefLink = aRefLinks[i];
if (pRefLink->Update())
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index ded749f222d4..525bbce04c4a 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2796,19 +2796,20 @@ void ScExternalRefManager::notifyAllLinkListeners(sal_uInt16 nFileId, LinkUpdate
void ScExternalRefManager::purgeStaleSrcDocument(sal_Int32 nTimeOut)
{
- DocShellMap aNewDocShells;
+ // To avoid potentially freezing Calc, we close one stale document at a time.
DocShellMap::iterator itr = maDocShells.begin(), itrEnd = maDocShells.end();
for (; itr != itrEnd; ++itr)
{
// in 100th of a second.
sal_Int32 nSinceLastAccess = (Time( Time::SYSTEM ) - itr->second.maLastAccess).GetTime();
- if (nSinceLastAccess < nTimeOut)
- aNewDocShells.insert(*itr);
- else
- // Timed out. Let's close this.
+ if (nSinceLastAccess >= nTimeOut)
+ {
+ // Timed out. Let's close this, and exit the loop.
itr->second.maShell->DoClose();
+ maDocShells.erase(itr);
+ break;
+ }
}
- maDocShells.swap(aNewDocShells);
if (maDocShells.empty())
maSrcDocTimer.Stop();