[Libreoffice-commits] core.git: Branch 'private/kohei/external-ref-refresh' - sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue May 20 07:20:18 PDT 2014


 sc/source/core/data/documen8.cxx         |    2 +-
 sc/source/ui/docshell/externalrefmgr.cxx |   13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit e274a615f99c96359fed477a8532c7693917a8f4
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue May 20 10:19:25 2014 -0400

    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

diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 4563b02..6b2f028 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 ded749f..525bbce 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();


More information about the Libreoffice-commits mailing list