Kaydet (Commit) e824a49a authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

Don't run the OLEObjCache timer for an empty cache

Change-Id: I210f6bdec14491bea6d15bca133011059091f21b
üst 9ac2aad4
......@@ -179,7 +179,6 @@ class OLEObjCache
size_t nSize;
AutoTimer* pTimer;
void UnloadOnDemand();
static bool UnloadObj( SdrOle2Obj* pObj );
DECL_LINK( UnloadCheckHdl, Timer*, void );
......
......@@ -59,11 +59,17 @@ public:
void SetTimeout( sal_uInt64 nTimeoutMs );
sal_uInt64 GetTimeout() const { return mnTimeout; }
/**
* Activates the timer task
*
* If the timer is already active, it's reset!
* Check with Task::IsActive() to prevent reset.
*/
virtual void Start() override;
};
/// An auto-timer is a multi-shot timer re-emitting itself at
/// interval until destroyed.
/// interval until destroyed or stopped.
class VCL_DLLPUBLIC AutoTimer : public Timer
{
public:
......
......@@ -112,8 +112,6 @@ OLEObjCache::OLEObjCache()
pTimer = new AutoTimer( "svx OLEObjCache pTimer UnloadCheck" );
pTimer->SetInvokeHandler( LINK(this, OLEObjCache, UnloadCheckHdl) );
pTimer->SetTimeout(20000);
pTimer->Invoke();
pTimer->Start();
}
OLEObjCache::~OLEObjCache()
......@@ -122,7 +120,7 @@ OLEObjCache::~OLEObjCache()
delete pTimer;
}
void OLEObjCache::UnloadOnDemand()
IMPL_LINK_NOARG(OLEObjCache, UnloadCheckHdl, Timer*, void)
{
if (nSize >= maObjs.size())
return;
......@@ -190,11 +188,12 @@ void OLEObjCache::InsertObj(SdrOle2Obj* pObj)
// insert object into first position
maObjs.insert(maObjs.begin(), pObj);
if ( !bFound )
{
// a new object was inserted, recalculate the cache
UnloadOnDemand();
}
// if a new object was inserted, recalculate the cache
if (!bFound)
pTimer->Invoke();
if (!bFound || !pTimer->IsActive())
pTimer->Start();
}
void OLEObjCache::RemoveObj(SdrOle2Obj* pObj)
......@@ -202,6 +201,8 @@ void OLEObjCache::RemoveObj(SdrOle2Obj* pObj)
std::vector<SdrOle2Obj*>::iterator it = std::find(maObjs.begin(), maObjs.end(), pObj);
if (it != maObjs.end())
maObjs.erase(it);
if (maObjs.empty())
pTimer->Stop();
}
size_t OLEObjCache::size() const
......@@ -243,12 +244,6 @@ bool OLEObjCache::UnloadObj(SdrOle2Obj* pObj)
return bUnloaded;
}
IMPL_LINK_NOARG(OLEObjCache, UnloadCheckHdl, Timer*, void)
{
UnloadOnDemand();
}
bool GetDraftFillColor(const SfxItemSet& rSet, Color& rCol)
{
drawing::FillStyle eFill=static_cast<const XFillStyleItem&>(rSet.Get(XATTR_FILLSTYLE)).GetValue();
......
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