summaryrefslogtreecommitdiff
path: root/sw/source/core/ole/ndole.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mikekaganski@hotmail.com>2015-05-18 00:03:41 +1000
committerMichael Stahl <mstahl@redhat.com>2015-05-19 14:44:20 +0000
commitb717bda1f6484905aebc571c4538165a1fbfd2bb (patch)
treeadb3b49e05e9d89a8482a395c4b6a22c5ce30961 /sw/source/core/ole/ndole.cxx
parent9c9db85643866ea57757a532d232e05a88de5fb8 (diff)
tdf#67421: Prevent unloading objects due to cache full
When an object is added to OLE objects cache, when cache is full, old objects are tried to be unloaded. This triggers notifications that cause all loaded objects to become active, and to be added to cache (moved to front). As the new object already was added to front of the cache, later activity pushes it to back, until it is the last object in cache. The cache in this process is overfilled, so each next refresh tries to unload current last OLE object. So, in the end, this effectively unloads all cached OLE objects. This patch prevents this by first unloading last object, and then adding new object to front of cache. Also, removed needless creation of reference (makes at least 200 function calls for no reason). Change-Id: Ia903f4df101971df1b0b0148320fc8e45ac1e79c Reviewed-on: https://gerrit.libreoffice.org/15772 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw/source/core/ole/ndole.cxx')
-rw-r--r--sw/source/core/ole/ndole.cxx6
1 files changed, 2 insertions, 4 deletions
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index 649d0b74744a..d69ddd98c745 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -972,18 +972,16 @@ void SwOLELRUCache::InsertObj( SwOLEObj& rObj )
}
if (it == m_OleObjects.end())
{
- m_OleObjects.push_front( pObj );
-
// try to remove objects if necessary
- // (of course not the freshly inserted one at nPos=0)
sal_Int32 nCount = m_OleObjects.size();
sal_Int32 nPos = nCount-1;
- while (nPos && nCount > m_nLRU_InitSize)
+ while (nPos >= 0 && nCount >= m_nLRU_InitSize)
{
pObj = m_OleObjects[ nPos-- ];
if ( pObj->UnloadObject() )
nCount--;
}
+ m_OleObjects.push_front(&rObj);
}
}