Kaydet (Commit) 2e92df04 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Scope reduction.

Change-Id: Ibc9314320c7b22f676978bb8b8157844a12c9bf8
üst af4aaa22
...@@ -115,51 +115,51 @@ OLEObjCache::~OLEObjCache() ...@@ -115,51 +115,51 @@ OLEObjCache::~OLEObjCache()
void OLEObjCache::UnloadOnDemand() void OLEObjCache::UnloadOnDemand()
{ {
if (nSize < maObjs.size()) if (nSize >= maObjs.size())
return;
// more objects than configured cache size try to remove objects
// of course not the freshly inserted one at nIndex=0
size_t nCount2 = maObjs.size();
size_t nIndex = nCount2-1;
while( nIndex && nCount2 > nSize )
{ {
// more objects than configured cache size try to remove objects SdrOle2Obj* pUnloadObj = maObjs[nIndex--];
// of course not the freshly inserted one at nIndex=0 if (!pUnloadObj)
size_t nCount2 = maObjs.size(); continue;
size_t nIndex = nCount2-1;
while( nIndex && nCount2 > nSize ) try
{ {
SdrOle2Obj* pUnloadObj = maObjs[nIndex--]; // it is important to get object without reinitialization to avoid reentrance
if ( pUnloadObj ) uno::Reference< embed::XEmbeddedObject > xUnloadObj = pUnloadObj->GetObjRef_NoInit();
{
try
{
// it is important to get object without reinitialization to avoid reentrance
uno::Reference< embed::XEmbeddedObject > xUnloadObj = pUnloadObj->GetObjRef_NoInit();
bool bUnload = SdrOle2Obj::CanUnloadRunningObj( xUnloadObj, pUnloadObj->GetAspect() ); bool bUnload = SdrOle2Obj::CanUnloadRunningObj( xUnloadObj, pUnloadObj->GetAspect() );
// check whether the object can be unloaded before looking for the parent objects // check whether the object can be unloaded before looking for the parent objects
if ( xUnloadObj.is() && bUnload ) if ( xUnloadObj.is() && bUnload )
{
uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY );
if ( xUnloadModel.is() )
{
for (size_t nCheckInd = 0; nCheckInd < maObjs.size(); nCheckInd++)
{ {
uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY ); SdrOle2Obj* pCacheObj = maObjs[nCheckInd];
if ( xUnloadModel.is() ) if ( pCacheObj && pCacheObj != pUnloadObj )
{ {
for (size_t nCheckInd = 0; nCheckInd < maObjs.size(); nCheckInd++) uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel();
{ if ( xUnloadModel == xParentModel )
SdrOle2Obj* pCacheObj = maObjs[nCheckInd]; bUnload = false; // the object has running embedded objects
if ( pCacheObj && pCacheObj != pUnloadObj )
{
uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel();
if ( xUnloadModel == xParentModel )
bUnload = false; // the object has running embedded objects
}
}
} }
} }
if ( bUnload && UnloadObj(pUnloadObj) )
// object was successfully unloaded
nCount2--;
} }
catch( uno::Exception& )
{}
} }
if ( bUnload && UnloadObj(pUnloadObj) )
// object was successfully unloaded
nCount2--;
} }
catch( uno::Exception& )
{}
} }
} }
......
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