[Libreoffice-commits] core.git: include/svx include/vcl svx/source

Jan-Marek Glogowski glogow at fbihome.de
Wed Sep 6 12:41:30 UTC 2017


 include/svx/svdetc.hxx       |    1 -
 include/vcl/timer.hxx        |    8 +++++++-
 svx/source/svdraw/svdetc.cxx |   23 +++++++++--------------
 3 files changed, 16 insertions(+), 16 deletions(-)

New commits:
commit e824a49a1c12533047d6a5ab8544377e8ff29863
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Thu Aug 24 18:54:21 2017 +0200

    Don't run the OLEObjCache timer for an empty cache
    
    Change-Id: I210f6bdec14491bea6d15bca133011059091f21b

diff --git a/include/svx/svdetc.hxx b/include/svx/svdetc.hxx
index 171e8d1318ba..33e6a8fbeec1 100644
--- a/include/svx/svdetc.hxx
+++ b/include/svx/svdetc.hxx
@@ -179,7 +179,6 @@ class OLEObjCache
     size_t         nSize;
     AutoTimer*          pTimer;
 
-    void UnloadOnDemand();
     static bool UnloadObj( SdrOle2Obj* pObj );
     DECL_LINK( UnloadCheckHdl, Timer*, void );
 
diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index d26004cc5312..ad2206f1e41c 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -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:
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 7ea0e0b686ba..89c17590984c 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -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();


More information about the Libreoffice-commits mailing list