summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/core/bastyp/swcache.cxx32
1 files changed, 25 insertions, 7 deletions
diff --git a/sw/source/core/bastyp/swcache.cxx b/sw/source/core/bastyp/swcache.cxx
index 200c8f59f4ab..1bf45c0d1fdc 100644
--- a/sw/source/core/bastyp/swcache.cxx
+++ b/sw/source/core/bastyp/swcache.cxx
@@ -367,16 +367,34 @@ bool SwCache::Insert( SwCacheObj *pNew )
nPos = pObj->GetCachePos();
if ( pObj == m_pLast )
- { OSL_ENSURE( pObj->GetPrev(), "Last but no Prev" );
+ {
m_pLast = pObj->GetPrev();
- m_pLast->SetNext( nullptr );
+ assert(m_pLast); // must have capacity > 1
}
- else
+ if (pObj == m_pFirst)
{
- if ( pObj->GetPrev() )
- pObj->GetPrev()->SetNext( pObj->GetNext() );
- if ( pObj->GetNext() )
- pObj->GetNext()->SetPrev( pObj->GetPrev() );
+ if (pObj->GetNext())
+ {
+ m_pFirst = pObj->GetNext();
+ }
+ else
+ {
+ m_pFirst = pObj->GetPrev();
+ }
+ assert(m_pFirst); // must have capacity > 1
+ }
+ if (pObj == m_pRealFirst)
+ {
+ m_pRealFirst = pObj->GetNext();
+ assert(m_pRealFirst); // must have capacity > 1
+ }
+ if (pObj->GetPrev())
+ {
+ pObj->GetPrev()->SetNext( pObj->GetNext() );
+ }
+ if (pObj->GetNext())
+ {
+ pObj->GetNext()->SetPrev( pObj->GetPrev() );
}
delete pObj;
m_aCacheObjects[nPos] = pNew;