[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - 8 commits - drawinglayer/source framework/source include/formula include/sal include/sfx2 include/vcl sfx2/source svtools/source toolkit/source vcl/inc vcl/source

Michael Meeks michael.meeks at collabora.com
Fri Nov 27 01:31:01 PST 2015


 drawinglayer/source/primitive2d/textlayoutdevice.cxx |    3 -
 framework/source/services/autorecovery.cxx           |    1 
 include/formula/funcutl.hxx                          |    1 
 include/sal/log-areas.dox                            |    1 
 include/sfx2/objsh.hxx                               |   12 ----
 include/vcl/dialog.hxx                               |    1 
 include/vcl/edit.hxx                                 |    6 +-
 include/vcl/idle.hxx                                 |    3 -
 include/vcl/scheduler.hxx                            |   33 +++++-------
 include/vcl/timer.hxx                                |    3 -
 include/vcl/toolbox.hxx                              |    7 +-
 sfx2/source/inc/objshimp.hxx                         |   12 ++++
 svtools/source/control/tabbar.cxx                    |    1 
 toolkit/source/awt/vclxtoolkit.cxx                   |    2 
 vcl/inc/saltimer.hxx                                 |   17 ++++++
 vcl/source/app/idle.cxx                              |   11 +++-
 vcl/source/app/scheduler.cxx                         |   51 +++++++++++++++++--
 vcl/source/app/svapp.cxx                             |    8 ++
 vcl/source/app/timer.cxx                             |   15 +++--
 vcl/source/control/edit.cxx                          |    6 ++
 vcl/source/window/toolbox.cxx                        |    9 ++-
 vcl/source/window/toolbox2.cxx                       |    5 +
 22 files changed, 152 insertions(+), 56 deletions(-)

New commits:
commit ed4d8c89ee954b3c9340583c95e8622a6cb47b3b
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Nov 26 11:15:11 2015 +0000

    vcl: reduce pointless timer / scheduler / idle includes.
    
    Change-Id: I8bf7f8d6ba1a54f2969e055956fadc52ff6c8673

diff --git a/include/formula/funcutl.hxx b/include/formula/funcutl.hxx
index f0ea363..e6d03be 100644
--- a/include/formula/funcutl.hxx
+++ b/include/formula/funcutl.hxx
@@ -23,6 +23,7 @@
 #include <vcl/fixed.hxx>
 #include <vcl/button.hxx>
 #include <vcl/edit.hxx>
+#include <vcl/idle.hxx>
 #include <formula/formuladllapi.h>
 
 namespace formula {
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 8eca878..09f8f07 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -37,7 +37,6 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/document/CmisVersion.hpp>
 
-#include <vcl/timer.hxx>
 #include <vcl/vclptr.hxx>
 #include <svl/poolitem.hxx>
 #include <vcl/bitmap.hxx>
@@ -805,17 +804,6 @@ inline SfxObjectShellLock & SfxObjectShellLock::
 inline SfxObjectShellLock & SfxObjectShellLock::operator = ( SfxObjectShell * pObjP )
 { return *this = SfxObjectShellLock( pObjP ); }
 
-class AutoReloadTimer_Impl : public Timer
-{
-    OUString          aUrl;
-    SfxObjectShell*   pObjSh;
-
-public:
-    AutoReloadTimer_Impl( const OUString& rURL, sal_uInt32 nTime,
-                          SfxObjectShell* pSh );
-    virtual void Invoke() override;
-};
-
 class SFX2_DLLPUBLIC SfxObjectShellItem: public SfxPoolItem
 {
     SfxObjectShell*         pObjSh;
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index d4bbe5c..eb4a2fd 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -23,7 +23,6 @@
 #include <tools/solar.h>
 #include <vcl/dllapi.h>
 #include <vcl/syswin.hxx>
-#include <vcl/timer.hxx>
 #include <vcl/vclptr.hxx>
 
 // - Dialog -
diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx
index da5dc16..3e6fbb7 100644
--- a/include/vcl/edit.hxx
+++ b/include/vcl/edit.hxx
@@ -27,8 +27,6 @@
 
 #include <tools/solar.h>
 #include <vcl/dllapi.h>
-#include <vcl/timer.hxx>
-#include <vcl/idle.hxx>
 #include <vcl/menu.hxx>
 #include <vcl/dndhelp.hxx>
 #include <vcl/vclptr.hxx>
@@ -70,6 +68,8 @@ public:
 
 enum AutocompleteAction{ AUTOCOMPLETE_KEYINPUT, AUTOCOMPLETE_TABFORWARD, AUTOCOMPLETE_TABBACKWARD };
 
+class Timer;
+
 // - Edit -
 class VCL_DLLPUBLIC Edit : public Control, public vcl::unohelper::DragAndDropClient
 {
@@ -205,7 +205,7 @@ public:
     virtual bool        IsModified() const { return mpSubEdit ? mpSubEdit->mbModified : mbModified; }
 
     virtual void        EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT );
-    virtual void        DisableUpdateData() { delete mpUpdateDataTimer; mpUpdateDataTimer = nullptr; }
+    virtual void        DisableUpdateData();
 
     void                SetEchoChar( sal_Unicode c );
     sal_Unicode         GetEchoChar() const { return mcEchoChar; }
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index a2e5a0a..e0b4fd7 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -25,12 +25,10 @@
 #include <vcl/dllapi.h>
 #include <vcl/dockwin.hxx>
 #include <vcl/image.hxx>
-#include <vcl/timer.hxx>
-#include <vcl/idle.hxx>
 #include <vector>
 
+class Timer;
 class UserDrawEvent;
-
 struct ImplToolItem;
 struct ImplToolSize;
 struct ImplToolBoxPrivateData;
@@ -67,6 +65,7 @@ struct ImplToolSize
     sal_uInt16 mnLines;
 };
 
+class Idle;
 class VCL_DLLPUBLIC ToolBox : public DockingWindow
 {
     friend class FloatingWindow;
@@ -76,7 +75,7 @@ private:
     ImplToolBoxPrivateData*   mpData;
     std::vector<ImplToolSize> maFloatSizes;
     ImageList           maImageList;
-    Idle                maIdle;
+    Idle               *mpIdle;
     Rectangle           maUpperRect;
     Rectangle           maLowerRect;
     Rectangle           maOutDockRect;
diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx
index a631003..737dd1f 100644
--- a/sfx2/source/inc/objshimp.hxx
+++ b/sfx2/source/inc/objshimp.hxx
@@ -30,6 +30,7 @@
 #include <sfx2/objsh.hxx>
 #include <sfx2/docmacromode.hxx>
 #include "bitset.hxx"
+#include <vcl/timer.hxx>
 
 #include <appbaslib.hxx>
 
@@ -45,6 +46,17 @@ struct MarkData_Impl
 
 class SfxBasicManagerHolder;
 
+class AutoReloadTimer_Impl : public Timer
+{
+    OUString          aUrl;
+    SfxObjectShell*   pObjSh;
+
+public:
+    AutoReloadTimer_Impl( const OUString& rURL, sal_uInt32 nTime,
+                          SfxObjectShell* pSh );
+    virtual void Invoke() override;
+};
+
 struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess
 {
     ::comphelper::EmbeddedObjectContainer* mpObjectContainer;
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index eb2f5aa..a71036b 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -35,6 +35,7 @@
 #include <svtools/svtools.hrc>
 #include <limits>
 #include <utility>
+#include <vcl/idle.hxx>
 
 namespace
 {
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index dbd8233..4b1056c 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -2463,6 +2463,12 @@ void Edit::EnableUpdateData( sal_uLong nTimeout )
     }
 }
 
+void Edit::DisableUpdateData()
+{
+    delete mpUpdateDataTimer;
+    mpUpdateDataTimer = nullptr;
+}
+
 void Edit::SetEchoChar( sal_Unicode c )
 {
     mcEchoChar = c;
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 6b4db05..4105b58 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1398,8 +1398,9 @@ void ToolBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
     mnKeyModifier     = 0;
     mnActivateCount   = 0;
 
-    maIdle.SetPriority( SchedulerPriority::RESIZE );
-    maIdle.SetIdleHdl( LINK( this, ToolBox, ImplUpdateHdl ) );
+    mpIdle = new Idle("toolbox update");
+    mpIdle->SetPriority( SchedulerPriority::RESIZE );
+    mpIdle->SetIdleHdl( LINK( this, ToolBox, ImplUpdateHdl ) );
 
     // set timeout and handler for dropdown items
     mpData->maDropdownTimer.SetTimeout( 250 );
@@ -1657,6 +1658,10 @@ void ToolBox::dispose()
         }
     }
     mpFloatWin.clear();
+
+    delete mpIdle;
+    mpIdle = nullptr;
+
     DockingWindow::dispose();
 }
 
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 72a3b58..dddb65f 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -25,6 +25,7 @@
 #include <tools/rc.h>
 
 #include <vcl/svapp.hxx>
+#include <vcl/idle.hxx>
 #include <vcl/help.hxx>
 #include <vcl/bitmap.hxx>
 #include <vcl/toolbox.hxx>
@@ -357,7 +358,7 @@ void ToolBox::ImplInvalidate( bool bNewCalc, bool bFullPaint )
         {
             Invalidate( Rectangle( mnLeftBorder, mnTopBorder,
                                    mnDX-mnRightBorder-1, mnDY-mnBottomBorder-1 ) );
-            maIdle.Stop();
+            mpIdle->Stop();
         }
     }
     else
@@ -368,7 +369,7 @@ void ToolBox::ImplInvalidate( bool bNewCalc, bool bFullPaint )
 
             // do we need to redraw?
             if ( IsReallyVisible() && IsUpdateMode() )
-                maIdle.Start();
+                mpIdle->Start();
         }
     }
 
commit 2c854ebae5879149261d6314061f43a379e32568
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Nov 26 10:42:10 2015 +0000

    vcl: fix event processing to idle - for JUnit tests.
    
    Change-Id: Ibeb1f6627815fc34c6e166357c88e076b75f6abb
    Reviewed-on: https://gerrit.libreoffice.org/20197
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index 6dd8030..13d1687 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -92,8 +92,10 @@ public:
     static void CallbackTaskScheduling( bool ignore );
     /// Calculate minimum timeout - and return its value.
     static sal_uInt64 CalculateMinimumTimeout( bool &bHasActiveIdles );
-    /// Process one pending task ahead of time with highhest priority.
-    static void       ProcessTaskScheduling( bool bTimer );
+    /// Process one pending task ahead of time with highest priority.
+    static bool       ProcessTaskScheduling( bool bTimerOnly );
+    /// Process all events until we are idle
+    static void       ProcessEventsToIdle();
 };
 
 #endif // INCLUDED_VCL_SCHEDULER_HXX
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index a1100a8..72a0cb4 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -1912,7 +1912,7 @@ void SAL_CALL VCLXToolkit::processEventsToIdle()
     throw (css::uno::RuntimeException, std::exception)
 {
     SolarMutexGuard aSolarGuard;
-    Scheduler::ProcessTaskScheduling(false);
+    Scheduler::ProcessEventsToIdle();
 }
 
 OUString SAL_CALL VCLXToolkit::getHWOSConfInfo()
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index ba90cca..e176866 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -157,7 +157,7 @@ void Scheduler::CallbackTaskScheduling(bool ignore)
     Scheduler::ProcessTaskScheduling( false );
 }
 
-void Scheduler::ProcessTaskScheduling( bool bTimerOnly )
+bool Scheduler::ProcessTaskScheduling( bool bTimerOnly )
 {
     ImplSchedulerData* pSchedulerData;
 
@@ -168,6 +168,23 @@ void Scheduler::ProcessTaskScheduling( bool bTimerOnly )
 
         pSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
         pSchedulerData->Invoke();
+        return true;
+    }
+    else
+        return false;
+}
+
+void Scheduler::ProcessEventsToIdle()
+{
+    // FIXME: really we should process incoming OS events too ...
+    int nSanity = 1000;
+    while (Scheduler::ProcessTaskScheduling(false))
+    {
+        if (nSanity-- < 0)
+        {
+            SAL_WARN("vcl.schedule", "Unexpected volume of events to process");
+            break;
+        }
     }
 }
 
commit 5fef25ead2caecde863eb2dae2c0da3070049d1b
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Nov 25 23:38:09 2015 +0000

    vcl: further fix debug name cleanup.
    
    Change-Id: Ia95c4893773bec77fe2ddf1a85e8687ab6776e10

diff --git a/vcl/inc/saltimer.hxx b/vcl/inc/saltimer.hxx
index 6bd3e07..c791a54 100644
--- a/vcl/inc/saltimer.hxx
+++ b/vcl/inc/saltimer.hxx
@@ -67,9 +67,7 @@ struct ImplSchedulerData
 
     void Invoke();
 
-    const char *GetDebugName() const
-        { return mpScheduler && mpScheduler->GetDebugName() ?
-                mpScheduler->GetDebugName() : "unknown"; }
+    const char *GetDebugName() const;
     static ImplSchedulerData *GetMostImportantTask( bool bTimer );
 };
 
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 210281f..ba90cca 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -330,4 +330,11 @@ Scheduler::~Scheduler()
     }
 }
 
+const char *ImplSchedulerData::GetDebugName() const
+{
+    return mpScheduler && mpScheduler->GetDebugName() ?
+        mpScheduler->GetDebugName() : "unknown";
+}
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 577736c3ce131d09e89df27b978b3d84e5bca380
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Nov 25 21:38:34 2015 +0000

    vcl: cleanup scheduler debug name usage.
    
    Change-Id: I94975d220452ca91cbbd9db5e7895fa0b3a88e4a

diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index da9af64..6dd8030 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -75,6 +75,7 @@ public:
     SchedulerPriority GetPriority() const { return mePriority; }
 
     void            SetDebugName( const sal_Char *pDebugName ) { mpDebugName = pDebugName; }
+    const char     *GetDebugName() { return mpDebugName; }
 
     // Call handler
     virtual void    Invoke() = 0;
diff --git a/vcl/inc/saltimer.hxx b/vcl/inc/saltimer.hxx
index 04427ad..6bd3e07 100644
--- a/vcl/inc/saltimer.hxx
+++ b/vcl/inc/saltimer.hxx
@@ -67,6 +67,9 @@ struct ImplSchedulerData
 
     void Invoke();
 
+    const char *GetDebugName() const
+        { return mpScheduler && mpScheduler->GetDebugName() ?
+                mpScheduler->GetDebugName() : "unknown"; }
     static ImplSchedulerData *GetMostImportantTask( bool bTimer );
 };
 
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 265d6f6..210281f 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -164,11 +164,7 @@ void Scheduler::ProcessTaskScheduling( bool bTimerOnly )
     // tdf#91727 - NB. bTimerOnly is ultimately not used
     if ((pSchedulerData = ImplSchedulerData::GetMostImportantTask(bTimerOnly)))
     {
-        // FIXME: move into a helper.
-        const char *pSchedulerName = pSchedulerData->mpScheduler->mpDebugName;
-        if (!pSchedulerName)
-            pSchedulerName = "unknown";
-        SAL_INFO("vcl.schedule", "Invoke task " << pSchedulerName);
+        SAL_INFO("vcl.schedule", "Invoke task " << pSchedulerData->GetDebugName());
 
         pSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
         pSchedulerData->Invoke();
@@ -208,22 +204,20 @@ sal_uInt64 Scheduler::CalculateMinimumTimeout( bool &bHasActiveIdles )
         {
             if (!pSchedulerData->mbInScheduler)
             {
-                // FIXME: move into a helper.
-                const char *pSchedulerName = pSchedulerData->mpScheduler->mpDebugName;
-                if (!pSchedulerName)
-                    pSchedulerName = "unknown";
-
                 if ( !pSchedulerData->mpScheduler->IsIdle() )
                 {
                     sal_uInt64 nOldMinPeriod = nMinPeriod;
                     nMinPeriod = pSchedulerData->mpScheduler->UpdateMinPeriod(
                                                                 nOldMinPeriod, nTime );
-                    SAL_INFO("vcl.schedule", "Have active timer " << pSchedulerName <<
-                        "update min period from " << nOldMinPeriod << " to " << nMinPeriod);
+                    SAL_INFO("vcl.schedule", "Have active timer " <<
+                             pSchedulerData->GetDebugName() <<
+                             "update min period from " << nOldMinPeriod <<
+                             " to " << nMinPeriod);
                 }
                 else
                 {
-                    SAL_INFO("vcl.schedule", "Have active idle " << pSchedulerName);
+                    SAL_INFO("vcl.schedule", "Have active idle " <<
+                             pSchedulerData->GetDebugName());
                     bHasActiveIdles = true;
                 }
             }
commit 3853d5ffbf118c83302973bc69c88a0e93e1f937
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Nov 25 10:35:37 2015 +0000

    vcl: move private impl. detail of Scheduler out of global header.
    
    Change-Id: Iee56131a15f9554c263406356456f65694515719

diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index 58da1bf..da9af64 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -22,20 +22,9 @@
 
 #include <vcl/dllapi.h>
 
-struct ImplSVData;
 class Scheduler;
-struct ImplSchedulerData
-{
-    ImplSchedulerData*  mpNext;      // Pointer to the next element in list
-    Scheduler*          mpScheduler;      // Pointer to VCL Scheduler instance
-    bool                mbDelete;    // Destroy this scheduler?
-    bool                mbInScheduler;    // Scheduler currently processed?
-    sal_uInt64          mnUpdateTime;   // Last Update Time
-
-    void Invoke();
-
-    static ImplSchedulerData *GetMostImportantTask( bool bTimer );
-};
+struct ImplSVData;
+struct ImplSchedulerData;
 
 enum class SchedulerPriority {
     HIGHEST   = 0,
diff --git a/vcl/inc/saltimer.hxx b/vcl/inc/saltimer.hxx
index 01a3012..04427ad 100644
--- a/vcl/inc/saltimer.hxx
+++ b/vcl/inc/saltimer.hxx
@@ -54,6 +54,22 @@ public:
     }
 };
 
+class Scheduler;
+
+// Internal scheduler record holding intrusive linked list pieces
+struct ImplSchedulerData
+{
+    ImplSchedulerData*  mpNext;        // Pointer to the next element in list
+    Scheduler*          mpScheduler;   // Pointer to VCL Scheduler instance
+    bool                mbDelete;      // Destroy this scheduler?
+    bool                mbInScheduler; // Scheduler currently processed?
+    sal_uInt64          mnUpdateTime;  // Last Update Time
+
+    void Invoke();
+
+    static ImplSchedulerData *GetMostImportantTask( bool bTimer );
+};
+
 #endif // INCLUDED_VCL_INC_SALTIMER_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx
index 9374b03..123f37a 100644
--- a/vcl/source/app/idle.cxx
+++ b/vcl/source/app/idle.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <vcl/idle.hxx>
+#include "saltimer.hxx"
 
 void Idle::Invoke()
 {
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index cf0a536..1766d7f 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -19,6 +19,7 @@
 
 #include <tools/time.hxx>
 #include <vcl/timer.hxx>
+#include "saltimer.hxx"
 
 void Timer::SetDeletionFlags()
 {
commit 695bb66fa3b594d29f8aa9d880212df5588cfb91
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Nov 25 21:33:15 2015 +0000

    vcl: don't treat non-ready timers as idle handlers.
    
    Fixes the busy-loop - 100% CPU all the time.
    
    Change-Id: I965f62d6a6f2ec1830c0897dd97179a739c70afc
    Reviewed-on: https://gerrit.libreoffice.org/20186
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx
index d746cf4..5460d33 100644
--- a/include/vcl/idle.hxx
+++ b/include/vcl/idle.hxx
@@ -39,7 +39,8 @@ public:
     void            SetIdleHdl( const Link<Idle *, void>& rLink ) { maIdleHdl = rLink; }
     const Link<Idle *, void>& GetIdleHdl() const { return maIdleHdl; }
     virtual void Invoke() override;
-    virtual bool ReadyForSchedule( bool bTimer ) const override;
+    virtual bool ReadyForSchedule( bool bTimerOnly, sal_uInt64 nTimeNow ) const override;
+    virtual bool IsIdle() const override;
     virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) const override;
     Idle&           operator=( const Idle& rIdle );
 };
diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index 5771f3a..58da1bf 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -67,8 +67,15 @@ protected:
 
     friend struct ImplSchedulerData;
     virtual void SetDeletionFlags();
-    virtual bool ReadyForSchedule( bool bTimer ) const = 0;
-    virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) const = 0;
+    /// Is this item ready to be dispatched at @nTimeNow
+    virtual bool ReadyForSchedule( bool bTimerOnly, sal_uInt64 nTimeNow ) const = 0;
+    /// Schedule only when other timers and events are processed
+    virtual bool IsIdle() const = 0;
+    /**
+     * Adjust @nMinPeriod downwards if we want to be notified before
+     * then, @nTimeNow is the current time.
+     */
+    virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTimeNow ) const = 0;
 
 public:
     Scheduler( const sal_Char *pDebugName = nullptr );
diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index 94a025e..149ba90 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -31,7 +31,8 @@ protected:
     bool            mbAuto;
 
     virtual void SetDeletionFlags() override;
-    virtual bool ReadyForSchedule( bool bTimer ) const override;
+    virtual bool ReadyForSchedule( bool bTimerOnly, sal_uInt64 nTimeNow ) const override;
+    virtual bool IsIdle() const override;
     virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) const override;
 
 public:
diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx
index bba2d05..9374b03 100644
--- a/vcl/source/app/idle.cxx
+++ b/vcl/source/app/idle.cxx
@@ -46,9 +46,15 @@ void Idle::Start()
     Scheduler::ImplStartTimer(Scheduler::ImmediateTimeoutMs);
 }
 
-bool Idle::ReadyForSchedule( bool bTimer ) const
+bool Idle::ReadyForSchedule( bool bTimerOnly, sal_uInt64 /* nTimeNow */ ) const
 {
-    return !bTimer;
+    // always ready if not only looking for timers.
+    return !bTimerOnly;
+}
+
+bool Idle::IsIdle() const
+{
+    return true;
 }
 
 sal_uInt64 Idle::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 /* nTime */ ) const
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 8e548bc..265d6f6 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -46,10 +46,11 @@ ImplSchedulerData *ImplSchedulerData::GetMostImportantTask( bool bTimerOnly )
     ImplSVData*     pSVData = ImplGetSVData();
     ImplSchedulerData *pMostUrgent = nullptr;
 
+    sal_uInt64 nTimeNow = tools::Time::GetSystemTicks();
     for ( ImplSchedulerData *pSchedulerData = pSVData->mpFirstSchedulerData; pSchedulerData; pSchedulerData = pSchedulerData->mpNext )
     {
         if ( !pSchedulerData->mpScheduler || pSchedulerData->mbDelete ||
-             !pSchedulerData->mpScheduler->ReadyForSchedule( bTimerOnly ) ||
+             !pSchedulerData->mpScheduler->ReadyForSchedule( bTimerOnly, nTimeNow ) ||
              !pSchedulerData->mpScheduler->IsActive())
             continue;
         if (!pMostUrgent)
@@ -207,10 +208,24 @@ sal_uInt64 Scheduler::CalculateMinimumTimeout( bool &bHasActiveIdles )
         {
             if (!pSchedulerData->mbInScheduler)
             {
-                if ( pSchedulerData->mpScheduler->ReadyForSchedule( true ) )
-                    nMinPeriod = pSchedulerData->mpScheduler->UpdateMinPeriod( nMinPeriod, nTime );
+                // FIXME: move into a helper.
+                const char *pSchedulerName = pSchedulerData->mpScheduler->mpDebugName;
+                if (!pSchedulerName)
+                    pSchedulerName = "unknown";
+
+                if ( !pSchedulerData->mpScheduler->IsIdle() )
+                {
+                    sal_uInt64 nOldMinPeriod = nMinPeriod;
+                    nMinPeriod = pSchedulerData->mpScheduler->UpdateMinPeriod(
+                                                                nOldMinPeriod, nTime );
+                    SAL_INFO("vcl.schedule", "Have active timer " << pSchedulerName <<
+                        "update min period from " << nOldMinPeriod << " to " << nMinPeriod);
+                }
                 else
+                {
+                    SAL_INFO("vcl.schedule", "Have active idle " << pSchedulerName);
                     bHasActiveIdles = true;
+                }
             }
             pPrevSchedulerData = pSchedulerData;
         }
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 4b0961e..cf0a536 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -30,9 +30,14 @@ void Timer::SetDeletionFlags()
     }
 }
 
-bool Timer::ReadyForSchedule( bool /* bTimerOnly */ ) const
+bool Timer::ReadyForSchedule( bool /* bTimerOnly */, sal_uInt64 nTimeNow ) const
 {
-    return (mpSchedulerData->mnUpdateTime + mnTimeout) <= tools::Time::GetSystemTicks();
+    return (mpSchedulerData->mnUpdateTime + mnTimeout) <= nTimeNow;
+}
+
+bool Timer::IsIdle() const
+{
+    return false;
 }
 
 sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) const
commit 0b533c23ef71d77fb5112769908fa9f39d5f552d
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Nov 25 21:27:36 2015 +0000

    vcl: improve scheduler debugging information.
    
    Change-Id: I6f7d7d3b5b027097417a15804a42aaaab4a03158
    Reviewed-on: https://gerrit.libreoffice.org/20185
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
index aa71798..5356785 100644
--- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx
+++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
@@ -73,7 +73,8 @@ namespace
     };
 
     ImpTimedRefDev::ImpTimedRefDev(scoped_timed_RefDev& rOwnerOfMe)
-    :   mrOwnerOfMe(rOwnerOfMe),
+    :   Timer( "Timer to destroy drawinglayer reference device" ),
+        mrOwnerOfMe(rOwnerOfMe),
         mpVirDev(nullptr),
         mnUseCount(0L)
     {
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index 8e765f0..9194db4 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -1257,6 +1257,7 @@ AutoRecovery::AutoRecovery(const css::uno::Reference< css::uno::XComponentContex
     , m_bListenForConfigChanges (false                                          )
     , m_nAutoSaveTimeIntervall  (0                                                  )
     , m_eJob                    (AutoRecovery::E_NO_JOB                             )
+    , m_aTimer                  ( "Auto save timer" )
     , m_aAsyncDispatcher        ( LINK( this, AutoRecovery, implts_asyncDispatch )  )
     , m_eTimerType              (E_DONT_START_TIMER                                 )
     , m_nIdPool                 (0                                                  )
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index 83218a5..310fb12 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -432,6 +432,7 @@ certain functionality.
 @li @c vcl.osx.print
 @li @c vcl.quartz
 @li @c vcl.screensaverinhibitor
+ at li @c vcl.schedule - scheduler / main-loop information
 @li @c vcl.scrollbar - Scroll Bars
 @li @c vcl.sm - Session Manager
 @li @c vcl.unity
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 743de91..8e548bc 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -163,6 +163,12 @@ void Scheduler::ProcessTaskScheduling( bool bTimerOnly )
     // tdf#91727 - NB. bTimerOnly is ultimately not used
     if ((pSchedulerData = ImplSchedulerData::GetMostImportantTask(bTimerOnly)))
     {
+        // FIXME: move into a helper.
+        const char *pSchedulerName = pSchedulerData->mpScheduler->mpDebugName;
+        if (!pSchedulerName)
+            pSchedulerName = "unknown";
+        SAL_INFO("vcl.schedule", "Invoke task " << pSchedulerName);
+
         pSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
         pSchedulerData->Invoke();
     }
@@ -178,6 +184,7 @@ sal_uInt64 Scheduler::CalculateMinimumTimeout( bool &bHasActiveIdles )
     sal_uInt64         nTime = tools::Time::GetSystemTicks();
     sal_uInt64         nMinPeriod = MaximumTimeoutMs;
 
+    SAL_INFO("vcl.schedule", "Calculating minimum timeout:");
     pSchedulerData = pSVData->mpFirstSchedulerData;
     while ( pSchedulerData )
     {
@@ -217,10 +224,13 @@ sal_uInt64 Scheduler::CalculateMinimumTimeout( bool &bHasActiveIdles )
             pSVData->mpSalTimer->Stop();
         nMinPeriod = MaximumTimeoutMs;
         pSVData->mnTimerPeriod = nMinPeriod;
+        SAL_INFO("vcl.schedule", "Unusual - no more timers available - stop timer");
     }
     else
     {
         Scheduler::ImplStartTimer(nMinPeriod, true);
+        SAL_INFO("vcl.schedule", "Calculated minimum timeout as " << nMinPeriod << " and " <<
+                 (const char *)(bHasActiveIdles ? "has active idles" : "no idles"));
     }
 
     return nMinPeriod;
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 808e743..e9c4b01 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -477,6 +477,9 @@ inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
 {
     ImplSVData* pSVData = ImplGetSVData();
 
+    SAL_INFO("vcl.schedule", "Enter ImplYield: " << (i_bWait ? "wait" : "no wait") <<
+             ": " << (i_bAllEvents ? "all events" : "one event") << ": " << nReleased);
+
     bool bHasActiveIdles = false;
     sal_uInt64 nMinTimeout = 0;
     if (nReleased == 0) // else thread doesn't have SolarMutex so avoid race
@@ -505,6 +508,9 @@ inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
             i_bWait && !pSVData->maAppData.mbAppQuit,
             i_bAllEvents, nReleased);
 
+    SAL_INFO("vcl.schedule", "DoYield with " << (bHasActiveIdles ? "active idles" : "no ides") <<
+             " returns: " << (eResult == SalYieldResult::EVENT ? "processed event" : "timeout"));
+
     pSVData->maAppData.mnDispatchLevel--;
 
     DBG_TESTSOLARMUTEX(); // must be locked on return from Yield
@@ -515,6 +521,8 @@ inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
     // flush lazy deleted objects
     if( pSVData->maAppData.mnDispatchLevel == 0 )
         vcl::LazyDelete::flush();
+
+    SAL_INFO("vcl.schedule", "Leave ImplYield");
 }
 
 void Application::Reschedule( bool i_bAllEvents )
commit 48414578ee30fe3122a74eec783d706c3c821ed8
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Nov 25 21:06:59 2015 +0000

    vcl: timer - avoid expensive and pointless re-fetch of current time.
    
    Change-Id: I1423de820ec40340d2ddb9030106b813e488f2f3
    Reviewed-on: https://gerrit.libreoffice.org/20184
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index de7c52b..4b0961e 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -37,7 +37,6 @@ bool Timer::ReadyForSchedule( bool /* bTimerOnly */ ) const
 
 sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) const
 {
-    const sal_uInt64 nNewTime = tools::Time::GetSystemTicks();
     sal_uInt64 nDeltaTime;
     //determine smallest time slot
     if( mpSchedulerData->mnUpdateTime == nTime )
@@ -49,11 +48,11 @@ sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) con
     else
     {
         nDeltaTime = mpSchedulerData->mnUpdateTime + mnTimeout;
-        if( nDeltaTime < nNewTime )
+        if( nDeltaTime < nTime )
             nMinPeriod = ImmediateTimeoutMs;
         else
         {
-            nDeltaTime -= nNewTime;
+            nDeltaTime -= nTime;
             if( nDeltaTime < nMinPeriod )
                 nMinPeriod = nDeltaTime;
         }


More information about the Libreoffice-commits mailing list