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