Kaydet (Commit) 65d026f3 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst c28aadc7
......@@ -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())
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment