Kaydet (Commit) 5c2ec558 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

Avoid an image loss situation of auto swapping

Before an image data is used GraphicObject should be swapped in.
When a GraphicObject is swapped in auto swapping mechanism
is triggered which can swap out some of the images.
We should avoid to swap out the same image on which the swap
in method was called before because the caller code assumes that
the image data is there.

Change-Id: Ia4addc370742aea5fbf185cf87e3c062a5ebf5be
üst ccdf5581
...@@ -615,7 +615,7 @@ private: ...@@ -615,7 +615,7 @@ private:
// For 32Bit systems this leads to situations where graphics will be missing. This method will actively swap out // For 32Bit systems this leads to situations where graphics will be missing. This method will actively swap out
// the longest swapped in graphics until a maximum memory boundary (derived from user settings in tools/options/memory) // the longest swapped in graphics until a maximum memory boundary (derived from user settings in tools/options/memory)
// is no longer exceeded // is no longer exceeded
void SVT_DLLPRIVATE ImplCheckSizeOfSwappedInGraphics(); void SVT_DLLPRIVATE ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGraphicToIgnore);
public: public:
GraphicManager( sal_uLong nCacheSize = 10000000UL, sal_uLong nMaxObjCacheSize = 2400000UL ); GraphicManager( sal_uLong nCacheSize = 10000000UL, sal_uLong nMaxObjCacheSize = 2400000UL );
......
...@@ -70,7 +70,7 @@ void GraphicObject::ImplAfterDataChange() ...@@ -70,7 +70,7 @@ void GraphicObject::ImplAfterDataChange()
// check memory footprint of all GraphicObjects managed and evtl. take action // check memory footprint of all GraphicObjects managed and evtl. take action
if (mpMgr) if (mpMgr)
mpMgr->ImplCheckSizeOfSwappedInGraphics(); mpMgr->ImplCheckSizeOfSwappedInGraphics(this);
} }
GraphicObject::GraphicObject( const GraphicManager* pMgr ) : GraphicObject::GraphicObject( const GraphicManager* pMgr ) :
......
...@@ -192,7 +192,7 @@ namespace ...@@ -192,7 +192,7 @@ namespace
}; };
} // end of anonymous namespace } // end of anonymous namespace
void GraphicManager::ImplCheckSizeOfSwappedInGraphics() void GraphicManager::ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGraphicToIgnore)
{ {
// get the currently used memory footprint of all swapped in bitmap graphics // get the currently used memory footprint of all swapped in bitmap graphics
// of this graphic manager. Remember candidates in a vector. The size in bytes is // of this graphic manager. Remember candidates in a vector. The size in bytes is
...@@ -205,7 +205,7 @@ void GraphicManager::ImplCheckSizeOfSwappedInGraphics() ...@@ -205,7 +205,7 @@ void GraphicManager::ImplCheckSizeOfSwappedInGraphics()
for (size_t i = 0, n = maObjList.size(); i < n; ++i) for (size_t i = 0, n = maObjList.size(); i < n; ++i)
{ {
pObj = maObjList[i]; pObj = maObjList[i];
if (pObj->meType == GRAPHIC_BITMAP && !pObj->IsSwappedOut() && pObj->GetSizeBytes()) if (pObj->meType == GRAPHIC_BITMAP && !pObj->IsSwappedOut() && pObj->GetSizeBytes() && pObj != pGraphicToIgnore)
{ {
aCandidates.push_back(pObj); aCandidates.push_back(pObj);
size_t const nSize = pObj->GetSizeBytes(); size_t const nSize = pObj->GetSizeBytes();
......
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