[Libreoffice-commits] core.git: Branch 'feature/new-vcl-scheduler' - 1044 commits - accessibility/inc accessibility/source apple_remote/source avmedia/inc avmedia/Module_avmedia.mk avmedia/source basctl/inc basctl/source basctl/uiconfig basegfx/source basegfx/test basic/qa basic/source bean/native bin/check-elf-dynamic-objects bin/count-src-resources bin/count-todo-dialogs bin/dump-poolitems-values.py bin/module-deps.pl bin/removetooltip_markups.sh bin/test-hid-vs-ui.py bridges/inc bridges/source canvas/source chart2/inc chart2/source chart2/uiconfig codemaker/source comphelper/Library_comphelper.mk comphelper/source compilerplugins/clang configmgr/qa configmgr/source configure.ac connectivity/qa connectivity/source cppcanvas/source cppuhelper/source cui/source cui/uiconfig dbaccess/source dbaccess/uiconfig dbaccess/win32 desktop/Executable_unopkg_com.mk desktop/inc desktop/qa desktop/source desktop/win32 dictionaries download.lst drawinglayer/source dtrans/Library_dnd.mk dtrans/source editeng/so urce embeddedobj/source embeddedobj/test embedserv/source extensions/source extensions/test extensions/uiconfig external/clucene external/firebird external/harfbuzz external/liblangtag external/liborcus external/nss external/poppler external/unixODBC extras/source filter/source forms/source formula/source fpicker/Library_fps.mk fpicker/source fpicker/test fpicker/uiconfig framework/dtd framework/inc framework/Library_fwk.mk framework/qa framework/source framework/uiconfig helpcompiler/inc helpcontent2 hwpfilter/source i18nlangtag/qa i18npool/qa i18npool/source i18nutil/source icon-themes/breeze icon-themes/breeze_dark icon-themes/elementary icon-themes/galaxy icon-themes/sifr icon-themes/tango idlc/inc idlc/source idl/inc idl/source include/basegfx include/basic include/canvas include/codemaker include/comphelper include/connectivity include/dbaccess include/drawinglayer include/editeng include/filter include/formula include/framework include/LibreOfficeKit include/oox include/osl i nclude/postwin.h include/rtl include/sal include/salhelper include/sfx2 include/sot include/svl include/svtools include/svx include/systools include/test include/toolkit include/tools include/ucbhelper include/unotools include/vbahelper include/vcl include/xmloff include/xmlreader instsetoo_native/CustomTarget_setup.mk ios/experimental jvmfwk/plugins jvmfwk/source libreofficekit/source lingucomponent/source linguistic/source lotuswordpro/source Makefile.in odk/examples odk/source offapi/com officecfg/files.mk officecfg/registry officecfg/util oox/source opencl/inc postprocess/CustomTarget_images.mk postprocess/CustomTarget_registry.mk postprocess/Rdb_services.mk pyuno/GeneratedPackage_python-core.mk pyuno/README pyuno/source pyuno/zipcore qadevOOo/Jar_OOoRunner.mk qadevOOo/JunitTest_qadevOOo_unoapi.mk qadevOOo/Module_qadevOOo.mk qadevOOo/objdsc qadevOOo/qa qadevOOo/runner qadevOOo/tests readlicense_oo/license README.md registry/Library_reg.mk reportdesign/inc reportdesign/source rep ortdesign/uiconfig reportdesign/UIConfig_dbreport.mk RepositoryExternal.mk Repository.mk rsc/inc rsc/source salhelper/qa sal/Library_sal.mk sal/Library_sal_textenc.mk sal/Library_uwinapi.mk sal/osl sal/qa sal/rtl sal/StaticLibrary_salcpprt.mk sal/systools sal/util sax/qa scaddins/source sc/CppunitTest_sc_anchor_test.mk sc/inc sc/Library_sc.mk sc/Module_sc.mk scp2/source sc/qa sc/res scripting/examples scripting/java scripting/source sc/sdi sc/source sc/uiconfig sc/UIConfig_scalc.mk sc/workben sd/AllLangResTarget_sd.mk sdext/source sd/inc sd/Library_sd.mk sd/qa sd/sdi sd/source sd/uiconfig sd/UIConfig_simpress.mk sd/xml setup_native/source sfx2/classification sfx2/inc sfx2/Library_sfx.mk sfx2/Package_classification.mk sfx2/sdi sfx2/source sfx2/uiconfig sfx2/UIConfig_sfx.mk shell/inc shell/qa shell/source slideshow/source slideshow/test solenv/bin solenv/gbuild solenv/gcc-wrappers solenv/gdb solenv/lldb solenv/Module_solenv.mk solenv/PythonTest_solenv_python.mk solenv/qa sot/source st armath/inc starmath/qa starmath/source starmath/uiconfig stoc/source stoc/test store/Library_store.mk store/source svgio/qa svl/Library_svl.mk svl/qa svl/source svl/unx svtools/inc svtools/Library_svt.mk svtools/qa svtools/source svx/AllLangResTarget_svx.mk svx/inc svx/Library_svxcore.mk svx/Library_svx.mk svx/qa svx/sdi svx/source svx/uiconfig svx/UIConfig_svx.mk svx/util svx/workben sw/CppunitTest_sw_ooxmlexport8.mk sw/CppunitTest_sw_ooxmlexport9.mk swext/mediawiki sw/inc sw/Library_sw.mk sw/Module_sw.mk sw/ooxmlexport_setup.mk sw/qa sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk TEMPLATE.SOURCECODE.HEADER test/Library_test_setupvcl.mk test/Library_test-setupvcl.mk test/Module_test.mk test/source toolkit/source tools/inc tools/qa tools/source translations tubes/source ucb/CppunitTest_ucb_webdav_res_access.mk ucbhelper/source ucb/Module_ucb.mk ucb/qa ucb/source uitest/calc_tests uitest/demo_ui uitest/impress_tests uitest/libreoffice uitest/test_main.py uitest/uitest UnoControl s/source unoidl/source unotools/source unoxml/source uui/source uui/uiconfig uui/util vbahelper/source vcl/AllLangResTarget_vcl.mk vcl/android vcl/backendtest vcl/CppunitTest_vcl_jpeg_read_write_test.mk vcl/glyphy vcl/headless vcl/inc vcl/ios vcl/Module_vcl.mk vcl/opengl vcl/osx vcl/qa vcl/quartz vcl/README.GDIMetaFile vcl/README.vars vcl/source vcl/unx vcl/win vcl/workben winaccessibility/inc winaccessibility/source wizards/com wizards/source writerfilter/source writerperfect/inc writerperfect/source xmlhelp/source xmloff/CppunitTest_xmloff_tokenmap.mk xmloff/CppunitTest_xmloff_uxmloff.mk xmloff/inc xmloff/Module_xmloff.mk xmloff/qa xmloff/source xmlsecurity/CppunitTest_xmlsecurity_signing.mk xmlsecurity/Executable_pdfverify.mk xmlsecurity/inc xmlsecurity/Library_xmlsecurity.mk xmlsecurity/Module_xmlsecurity.mk xmlsecurity/qa xmlsecurity/source xmlsecurity/test_docs xmlsecurity/workben

Jan-Marek Glogowski glogow at fbihome.de
Mon Oct 17 10:01:38 UTC 2016


Rebased ref, commits from common ancestor:
commit d63b893f4bd77f2b7136224fa747060276fd6fa0
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Fri Oct 14 16:05:58 2016 +0200

    Correctly handle nested task processing calls
    
    If ProcessTaskScheduling is called to process tasks while inside
    Invoke(), the assumptions about the list pointers in the parent
    call will be void.
    
    There would be two possible solutions:
      1. Nested calls are forbidden to change the list, except for
         adding tasks.
      2. The parent call must be informed of the changes and update
         the pointers.
    
    Since we want to be able to remove processed tasks in nested calls,
    we go with option 2, which has a slight overhead but won't exhaust
    memory, because it can't release processed tasks.
    
    Change-Id: I7a3910a9a4677988dff1d5a7648a67d66fb41056

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 27c4cfc..02ffdc1 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -318,6 +318,7 @@ struct ImplSVData
     ImplSchedulerData*      mpFirstSchedulerData = nullptr; // list of all running tasks
     ImplSchedulerData*      mpFreeSchedulerData = nullptr;  // list of all deleted tasks for reuse
     bool                    mbNeedsReschedule = false;      // was the list of tasks changed?
+    bool                    mbTaskRemoved = false;          // was a task removed
     sal_uInt64              mnTimerPeriod = 0;              // current timer period / sleep time
     sal_uInt64              mnLastUpdate = 0;               // last scheduler time
     SalTimer*               mpSalTimer = nullptr;           // interface to sal event loop/timers
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 239187a..d4f5b31 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -173,6 +173,7 @@ bool Scheduler::ProcessTaskScheduling( IdleRunPolicy eIdleRunPolicy )
     ImplSchedulerData *pPrevMostUrgent = nullptr;
     ImplSchedulerData *pMostUrgent = nullptr;
     sal_uInt64         nMinPeriod = InfiniteTimeoutMs;
+    bool               bIsNestedCall = false;
 
     SAL_INFO( "vcl.schedule", "==========  Start  ==========" );
 
@@ -187,7 +188,10 @@ bool Scheduler::ProcessTaskScheduling( IdleRunPolicy eIdleRunPolicy )
 #endif
         // Skip invoked task
         if ( pSchedulerData->mbInScheduler )
+        {
+            bIsNestedCall = true;
             goto next_entry;
+        }
 
         // Can this task be removed from scheduling?
         if ( !pSchedulerData->mpScheduler )
@@ -200,6 +204,7 @@ bool Scheduler::ProcessTaskScheduling( IdleRunPolicy eIdleRunPolicy )
             pSchedulerData->mpNext = pSVData->mpFreeSchedulerData;
             pSVData->mpFreeSchedulerData = pSchedulerData;
             pSchedulerData = pNextSchedulerData;
+            pSVData->mbTaskRemoved = true;
             continue;
         }
 
@@ -226,6 +231,10 @@ next_entry:
 
     assert( !pSchedulerData );
 
+    // We just have to handle removed tasks for nested calls
+    if ( !bIsNestedCall )
+        pSVData->mbTaskRemoved = false;
+
     if ( pMostUrgent )
     {
         assert( pPrevMostUrgent != pMostUrgent );
@@ -238,6 +247,14 @@ next_entry:
         SAL_INFO_IF( !pMostUrgent->mpScheduler, "vcl.schedule", tools::Time::GetSystemTicks()
                      << " " << pMostUrgent <<  "  tag-rm     " );
 
+        // If there were some tasks removed, our list pointers may be invalid,
+        // except pMostUrgent, which is protected by mbInScheduler
+        if ( pSVData->mbTaskRemoved )
+        {
+            nMinPeriod = ImmediateTimeoutMs;
+            pPrevSchedulerData = pMostUrgent;
+        }
+
         // do some simple round-robin scheduling
         // nothing to do, if we're already the last element
         if ( pMostUrgent->mpScheduler )
@@ -247,6 +264,19 @@ next_entry:
 
             if ( pMostUrgent->mpNext )
             {
+                // see ^^^^^
+                if ( pSVData->mbTaskRemoved )
+                {
+                    pPrevMostUrgent = pSVData->mpFirstSchedulerData;
+                    if ( pPrevMostUrgent != pMostUrgent )
+                    {
+                        while ( pPrevMostUrgent && pPrevMostUrgent->mpNext != pMostUrgent )
+                            pPrevMostUrgent = pPrevMostUrgent->mpNext;
+                        assert( pPrevMostUrgent );
+                    }
+                    else
+                        pPrevMostUrgent = nullptr;
+                }
                 if ( pPrevMostUrgent )
                     pPrevMostUrgent->mpNext = pMostUrgent->mpNext;
                 else
commit 70e2c718aae2f5844e522bbc43ff3ea482f38a76
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Tue Sep 13 11:03:08 2016 +0200

    Round-robin invoked auto tasks
    
    Add some simple round-robin to the task processing, so equal
    priority (auto) tasks won't always be scheduled, if there are
    multiple tasks with the same priority.
    
    Change-Id: If84496bff68aec42d0fa63c2b7e05c3202f67b2c

diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 082354b..239187a 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -30,9 +30,6 @@ void ImplSchedulerData::Invoke()
     if ( !mpScheduler || mbInScheduler )
         return;
 
-    // tdf#92036 Reset the period to avoid re-firing immediately.
-    mpScheduler->mpSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
-
     Scheduler *sched = mpScheduler;
 
     // prepare Scheduler Object for deletion after handling
@@ -173,6 +170,7 @@ bool Scheduler::ProcessTaskScheduling( IdleRunPolicy eIdleRunPolicy )
 
     ImplSchedulerData* pSchedulerData = pSVData->mpFirstSchedulerData;
     ImplSchedulerData* pPrevSchedulerData = nullptr;
+    ImplSchedulerData *pPrevMostUrgent = nullptr;
     ImplSchedulerData *pMostUrgent = nullptr;
     sal_uInt64         nMinPeriod = InfiniteTimeoutMs;
 
@@ -217,6 +215,7 @@ bool Scheduler::ProcessTaskScheduling( IdleRunPolicy eIdleRunPolicy )
             // Just account previous most urgent tasks
             if ( pMostUrgent )
                 UpdateMinPeriod( pMostUrgent, nTime, nMinPeriod );
+            pPrevMostUrgent = pPrevSchedulerData;
             pMostUrgent = pSchedulerData;
         }
 
@@ -229,6 +228,9 @@ next_entry:
 
     if ( pMostUrgent )
     {
+        assert( pPrevMostUrgent != pMostUrgent );
+        assert( !pPrevMostUrgent || (pPrevMostUrgent->mpNext == pMostUrgent) );
+
         Scheduler *pTempScheduler = pMostUrgent->mpScheduler;
         SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " << pMostUrgent << "  invoke     "
                    << (int) pTempScheduler->mePriority << " " << pTempScheduler->mpDebugName );
@@ -236,10 +238,28 @@ next_entry:
         SAL_INFO_IF( !pMostUrgent->mpScheduler, "vcl.schedule", tools::Time::GetSystemTicks()
                      << " " << pMostUrgent <<  "  tag-rm     " );
 
+        // do some simple round-robin scheduling
+        // nothing to do, if we're already the last element
         if ( pMostUrgent->mpScheduler )
         {
             pMostUrgent->mnUpdateTime = nTime;
             UpdateMinPeriod( pMostUrgent, nTime, nMinPeriod );
+
+            if ( pMostUrgent->mpNext )
+            {
+                if ( pPrevMostUrgent )
+                    pPrevMostUrgent->mpNext = pMostUrgent->mpNext;
+                else
+                    pSVData->mpFirstSchedulerData = pMostUrgent->mpNext;
+                // Invoke() might have changed the task list - find new end
+                while ( pPrevSchedulerData->mpNext )
+                {
+                    pPrevSchedulerData = pPrevSchedulerData->mpNext;
+                    UpdateMinPeriod( pPrevSchedulerData, nTime, nMinPeriod );
+                }
+                pPrevSchedulerData->mpNext = pMostUrgent;
+                pMostUrgent->mpNext = nullptr;
+            }
         }
     }
 
@@ -265,10 +285,10 @@ void Scheduler::Start()
 {
     ImplSVData *const pSVData = ImplGetSVData();
     if (pSVData->mbDeInit)
-    {
         return;
-    }
 
+    if ( mpSchedulerData && mpSchedulerData->mpNext )
+        Scheduler::SetDeletionFlags();
     if ( !mpSchedulerData )
     {
         // insert Scheduler
@@ -281,26 +301,21 @@ void Scheduler::Start()
             mpSchedulerData = new ImplSchedulerData;
         mpSchedulerData->mpScheduler   = this;
         mpSchedulerData->mbInScheduler = false;
+        mpSchedulerData->mpNext = nullptr;
 
         // insert last due to SFX!
-        ImplSchedulerData* pPrev = nullptr;
         ImplSchedulerData* pData = pSVData->mpFirstSchedulerData;
-        while ( pData )
+        if ( pData )
         {
-            pPrev = pData;
-            pData = pData->mpNext;
+            while ( pData->mpNext )
+                pData = pData->mpNext;
+            pData->mpNext = mpSchedulerData;
         }
-        mpSchedulerData->mpNext = nullptr;
-        if ( pPrev )
-            pPrev->mpNext = mpSchedulerData;
         else
             pSVData->mpFirstSchedulerData = mpSchedulerData;
         SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " << mpSchedulerData
              <<  "  added      " << (int) mePriority << " " << mpDebugName );
     }
-    else
-        SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " << mpSchedulerData
-             <<  "  restarted  " << (int) mePriority << " " << mpDebugName );
 
     assert( mpSchedulerData->mpScheduler == this );
     mpSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index fc450d1..fcc1b88 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -476,7 +476,7 @@ inline bool 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);
+             " / " << (i_bAllEvents ? "all events" : "one event") << " / " << nReleased);
 
     if ( i_bWait && Scheduler::HasPendingEvents() )
         i_bWait = false;
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 8e02235..15e1d62 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -76,7 +76,7 @@ void Timer::SetTimeout( sal_uInt64 nNewTimeout )
     // If timer is active, then renew clock.
     if ( IsActive() )
     {
-        Scheduler::ImplStartTimer(mnTimeout);
+        Start();
     }
 }
 
commit 2c91067e9ae47231cd31d1a577bf70506815b4e1
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Wed Aug 10 12:33:21 2016 +0200

    Readd SAL_INFOs to dump the Scheduler handling
    
    Debug area name is "vcl.schedule".
    
    Change-Id: Ia1eab69e76671bd33ce3324c5eb058e4e00dfdd2

diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 4f3d73a..082354b 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -176,8 +176,17 @@ bool Scheduler::ProcessTaskScheduling( IdleRunPolicy eIdleRunPolicy )
     ImplSchedulerData *pMostUrgent = nullptr;
     sal_uInt64         nMinPeriod = InfiniteTimeoutMs;
 
+    SAL_INFO( "vcl.schedule", "==========  Start  ==========" );
+
     while ( pSchedulerData )
     {
+#if OSL_DEBUG_LEVEL > 0
+        const Timer *timer = dynamic_cast<Timer*>( pSchedulerData->mpScheduler );
+        if ( timer )
+            SAL_INFO( "vcl.schedule", (dynamic_cast<const Idle*>( timer ) ? "Idle " : "Timer")
+                      << " " << (int) timer->GetPriority() << " " << pSchedulerData->mbInScheduler
+                      << " " << timer->GetTimeout() << " " << timer->GetDebugName() );
+#endif
         // Skip invoked task
         if ( pSchedulerData->mbInScheduler )
             goto next_entry;
@@ -220,7 +229,12 @@ next_entry:
 
     if ( pMostUrgent )
     {
+        Scheduler *pTempScheduler = pMostUrgent->mpScheduler;
+        SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " << pMostUrgent << "  invoke     "
+                   << (int) pTempScheduler->mePriority << " " << pTempScheduler->mpDebugName );
         pMostUrgent->Invoke();
+        SAL_INFO_IF( !pMostUrgent->mpScheduler, "vcl.schedule", tools::Time::GetSystemTicks()
+                     << " " << pMostUrgent <<  "  tag-rm     " );
 
         if ( pMostUrgent->mpScheduler )
         {
@@ -233,11 +247,14 @@ next_entry:
             && ((eIdleRunPolicy == IdleRunPolicy::IDLE_VIA_TIMER)
                 || (nMinPeriod > ImmediateTimeoutMs)) )
     {
+        SAL_INFO( "vcl.schedule", "Scheduler sleep timeout: " << nMinPeriod );
         ImplStartTimer( nMinPeriod, true );
     }
     else if ( pSVData->mpSalTimer )
         pSVData->mpSalTimer->Stop();
 
+    SAL_INFO( "vcl.schedule", "==========   End   ==========" );
+
     pSVData->mnTimerPeriod = nMinPeriod;
     pSVData->mnLastUpdate = nTime;
 
@@ -278,7 +295,12 @@ void Scheduler::Start()
             pPrev->mpNext = mpSchedulerData;
         else
             pSVData->mpFirstSchedulerData = mpSchedulerData;
+        SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " << mpSchedulerData
+             <<  "  added      " << (int) mePriority << " " << mpDebugName );
     }
+    else
+        SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " << mpSchedulerData
+             <<  "  restarted  " << (int) mePriority << " " << mpDebugName );
 
     assert( mpSchedulerData->mpScheduler == this );
     mpSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
@@ -289,7 +311,10 @@ void Scheduler::Stop()
 {
     if ( !mpSchedulerData )
         return;
+    ImplSchedulerData *pData = mpSchedulerData;
     Scheduler::SetDeletionFlags();
+    SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " << pData
+          << "  stopped    " << (int) mePriority << " " << mpDebugName );
     assert( !mpSchedulerData );
 }
 
commit 82b7950de271536c25bc61542d54761bec985607
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Wed Sep 14 18:17:18 2016 +0200

    Don't poll busy documents via idle task
    
    Creates a very busy idle-loop, for non-task work like mail merge.
    
    Change-Id: If7be82e4675008f23e6f4f6be5c40df40a231a8b

diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx
index 4a0176b..a7c5d23 100644
--- a/sw/source/core/doc/DocumentTimerManager.cxx
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -40,47 +40,50 @@ namespace sw
 DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ),
                                                                 mbStartIdleTimer( false ),
                                                                 mIdleBlockCount( 0 ),
-                                                                maIdle("DocumentTimerManagerIdleTimer")
+                                                                maDocIdleTimer("DocumentTimerManagerIdleTimer")
 {
-    maIdle.SetPriority( SchedulerPriority::LOWEST );
-    maIdle.SetIdleHdl( LINK( this, DocumentTimerManager, DoIdleJobs) );
-    maIdle.SetDebugName( "sw::DocumentTimerManager maIdle" );
+    maDocIdleTimer.SetPriority( SchedulerPriority::LOWEST );
+    maDocIdleTimer.SetTimeoutHdl( LINK( this, DocumentTimerManager, DoIdleJobs) );
+    maDocIdleTimer.SetDebugName( "sw::DocumentTimerManager maDocIdleTimer" );
 }
 
 void DocumentTimerManager::StartIdling()
 {
     mbStartIdleTimer = true;
     if( !mIdleBlockCount )
-        maIdle.Start();
+    {
+        maDocIdleTimer.SetTimeout( 0 );
+        maDocIdleTimer.Start();
+    }
 }
 
 void DocumentTimerManager::StopIdling()
 {
     mbStartIdleTimer = false;
-    maIdle.Stop();
+    maDocIdleTimer.Stop();
 }
 
 void DocumentTimerManager::BlockIdling()
 {
-    maIdle.Stop();
+    maDocIdleTimer.Stop();
     ++mIdleBlockCount;
 }
 
 void DocumentTimerManager::UnblockIdling()
 {
     --mIdleBlockCount;
-    if( !mIdleBlockCount && mbStartIdleTimer && !maIdle.IsActive() )
-        maIdle.Start();
+    if( !mIdleBlockCount && mbStartIdleTimer && !maDocIdleTimer.IsActive() )
+        maDocIdleTimer.Start();
 }
 
 void DocumentTimerManager::StartBackgroundJobs()
 {
     // Trigger DoIdleJobs(), asynchronously.
-    if (!maIdle.IsActive()) //fdo#73165 if the timer is already running don't restart from 0
-        maIdle.Start();
+    if (!maDocIdleTimer.IsActive()) //fdo#73165 if the timer is already running don't restart from 0
+        maDocIdleTimer.Start();
 }
 
-IMPL_LINK( DocumentTimerManager, DoIdleJobs, Idle*, pIdle, void )
+IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pTimer, void )
 {
 #ifdef TIMELOG
     static ::rtl::Logfile* pModLogFile = 0;
@@ -97,7 +100,8 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Idle*, pIdle, void )
         {
             if( rSh.ActionPend() )
             {
-                pIdle->Start();
+                pTimer->SetTimeout( 2000 );
+                pTimer->Start();
                 return;
             }
         }
@@ -121,7 +125,8 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Idle*, pIdle, void )
                 (*pLayIter)->GetCurrShell()->LayoutIdle();
 
                 // Defer the remaining work.
-                pIdle->Start();
+                pTimer->SetTimeout( 2000 );
+                pTimer->Start();
                 return;
             }
         }
@@ -137,7 +142,8 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Idle*, pIdle, void )
             if ( m_rDoc.getIDocumentFieldsAccess().GetUpdateFields().IsInUpdateFields() ||
                  m_rDoc.getIDocumentFieldsAccess().IsExpFieldsLocked() )
             {
-                pIdle->Start();
+                pTimer->SetTimeout( 2000 );
+                pTimer->Start();
                 return;
             }
 
diff --git a/sw/source/core/inc/DocumentTimerManager.hxx b/sw/source/core/inc/DocumentTimerManager.hxx
index b857519..17fa950 100644
--- a/sw/source/core/inc/DocumentTimerManager.hxx
+++ b/sw/source/core/inc/DocumentTimerManager.hxx
@@ -48,7 +48,7 @@ public:
     void StartBackgroundJobs() override;
 
     // Our own 'IdleTimer' calls the following method
-    DECL_LINK( DoIdleJobs, Idle *, void );
+    DECL_LINK( DoIdleJobs, Timer *, void );
 
     virtual ~DocumentTimerManager() override;
 
@@ -61,7 +61,7 @@ private:
 
     bool mbStartIdleTimer; //< idle timer mode start/stop
     sal_Int32 mIdleBlockCount;
-    Idle  maIdle;
+    Timer maDocIdleTimer;
 };
 
 }
commit 866efe068d6f4307fd1a30ffa0765bd744d7a220
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Wed Sep 14 15:33:54 2016 +0200

    Run Idle tasks immediatly
    
    There is really no reason to wait a millisecond for an idle.
    
    Change-Id: I7665d5f2e7d6ba3e01290a692bbc8e42c36b9986

diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index 3d4fde6..c1581eb 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -37,6 +37,12 @@ enum class SchedulerPriority
     LOWEST         ///< Low, very idle cleanup tasks
 };
 
+enum class IdleRunPolicy
+{
+    IDLE_VIA_TIMER,  ///< Idles are scheduled via immediate timers (ImmediateTimeoutMs)
+    IDLE_VIA_LOOP    ///< Return indicates processed events, so they are processed in a loop
+};
+
 class VCL_DLLPUBLIC Scheduler
 {
     friend struct ImplSchedulerData;
@@ -52,7 +58,7 @@ protected:
     const sal_Char     *mpDebugName;        /// Useful for debugging
     SchedulerPriority   mePriority;         /// Scheduler priority
 
-    static const SAL_CONSTEXPR sal_uInt64 ImmediateTimeoutMs = 1;
+    static const SAL_CONSTEXPR sal_uInt64 ImmediateTimeoutMs = 0;
     static const SAL_CONSTEXPR sal_uInt64 InfiniteTimeoutMs  = SAL_MAX_UINT64;
 
     static void ImplStartTimer(sal_uInt64 nMS, bool bForce = false);
@@ -82,12 +88,13 @@ public:
     inline bool     IsActive() const;
 
     Scheduler&      operator=( const Scheduler& rScheduler );
-    static void ImplDeInitScheduler();
+    static void     ImplDeInitScheduler();
 
     /// Process one pending Timer with highhest priority
     static void       CallbackTaskScheduling();
     /// Process one pending task ahead of time with highest priority.
-    static bool       ProcessTaskScheduling();
+    static bool       ProcessTaskScheduling( IdleRunPolicy eIdleRunPolicy
+                          = IdleRunPolicy::IDLE_VIA_TIMER );
     /// Process all events until we are idle
     static void       ProcessAllPendingEvents();
     /// Are there any pending tasks in the LO task queue?
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index b1406b9..4f3d73a 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -115,9 +115,6 @@ void Scheduler::ImplStartTimer( sal_uInt64 nMS, bool bForce )
         pSVData->mpSalTimer->SetCallback(Scheduler::CallbackTaskScheduling);
     }
 
-    if ( !nMS )
-        nMS = 1;
-
     // Only if smaller timeout, to avoid skipping.
     if (nMS < pSVData->mnTimerPeriod || (bForce && nMS != pSVData->mnTimerPeriod) )
     {
@@ -164,10 +161,9 @@ inline void Scheduler::UpdateMinPeriod( ImplSchedulerData *pSchedulerData,
 {
     if ( nMinPeriod > ImmediateTimeoutMs )
         pSchedulerData->mpScheduler->UpdateMinPeriod( nTime, nMinPeriod );
-    assert( nMinPeriod >= ImmediateTimeoutMs );
 }
 
-bool Scheduler::ProcessTaskScheduling()
+bool Scheduler::ProcessTaskScheduling( IdleRunPolicy eIdleRunPolicy )
 {
     ImplSVData*        pSVData = ImplGetSVData();
     sal_uInt64         nTime = tools::Time::GetSystemTicks();
@@ -233,8 +229,12 @@ next_entry:
         }
     }
 
-    if ( nMinPeriod != InfiniteTimeoutMs )
+    if ( nMinPeriod != InfiniteTimeoutMs
+            && ((eIdleRunPolicy == IdleRunPolicy::IDLE_VIA_TIMER)
+                || (nMinPeriod > ImmediateTimeoutMs)) )
+    {
         ImplStartTimer( nMinPeriod, true );
+    }
     else if ( pSVData->mpSalTimer )
         pSVData->mpSalTimer->Stop();
 
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 4ff2181..fc450d1 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -54,6 +54,7 @@
 #if HAVE_FEATURE_OPENGL
 #include <vcl/opengl/OpenGLWrapper.hxx>
 #endif
+#include <saltimer.hxx>
 
 #include "salinst.hxx"
 #include "salframe.hxx"
@@ -528,16 +529,33 @@ void Application::Reschedule( bool i_bAllEvents )
 
 void Scheduler::ProcessAllPendingEvents()
 {
-    int nSanity = 1000;
-    while( Scheduler::ProcessTaskScheduling() ||
-           ImplYield(false, true, 0) )
+    int nSanity = 1;
+    while( Scheduler::ProcessTaskScheduling( IdleRunPolicy::IDLE_VIA_LOOP )
+        || ImplYield( false, true, 0 ) )
     {
-        if (nSanity-- < 0)
+        if (0 == ++nSanity % 1000)
         {
-            SAL_WARN("vcl.schedule", "Unexpected volume of events to process");
-            break;
+            SAL_WARN("vcl.schedule", "ProcessAllPendingEvents: " << nSanity);
+        }
+    }
+#if OSL_DEBUG_LEVEL > 0
+    ImplSchedulerData* pSchedulerData = ImplGetSVData()->mpFirstSchedulerData;
+    bool bAnyIdle = false;
+    while ( pSchedulerData )
+    {
+        if ( pSchedulerData->mpScheduler && !pSchedulerData->mbInScheduler )
+        {
+            Idle *pIdle = dynamic_cast<Idle*>( pSchedulerData->mpScheduler );
+            if ( pIdle )
+            {
+                bAnyIdle = true;
+                SAL_WARN( "vcl.schedule",  "Unprocessed Idle: " << pSchedulerData->GetDebugName() );
+            }
         }
+        pSchedulerData = pSchedulerData->mpNext;
     }
+    assert( !bAnyIdle );
+#endif
 }
 
 void Application::Yield()
commit 339da942950204607e58412565d9b49089ce7c0b
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Wed Sep 14 13:48:02 2016 +0200

    Change Idle to be a Timer subclass
    
    Drops a lot of duplicated code and reflects the Scheduler
    handling of "Idle"s in the source code.
    
    Change-Id: I847592e92e86d15ab1cab168bf0e667322e48048

diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 9892435..52004df 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -1343,7 +1343,7 @@ void EditorWindow::DestroyProgress()
 void EditorWindow::ForceSyntaxTimeout()
 {
     aSyntaxIdle.Stop();
-    aSyntaxIdle.GetIdleHdl().Call(&aSyntaxIdle);
+    aSyntaxIdle.Invoke();
 }
 
 // BreakPointWindow
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index e091a14..66dae9b 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -810,7 +810,7 @@ void IdleFormattter::ForceTimeout()
     if ( IsActive() )
     {
         Stop();
-        ((Link<Idle *, void>&)GetIdleHdl()).Call( this );
+        Invoke();
     }
 }
 
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index bc00a7c..90e2b1b 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -2683,8 +2683,7 @@ throw( uno::RuntimeException, std::exception )
         m_bMustDoLayout = true;
         if ( !m_aAsyncLayoutTimer.IsActive() )
         {
-            const Link<Timer *, void>& aLink = m_aAsyncLayoutTimer.GetTimeoutHdl();
-            aLink.Call( &m_aAsyncLayoutTimer );
+            m_aAsyncLayoutTimer.Invoke();
         }
         if ( m_nLockCount == 0 )
             m_aAsyncLayoutTimer.Start();
diff --git a/include/tools/link.hxx b/include/tools/link.hxx
index 8b65be4..de76c25 100644
--- a/include/tools/link.hxx
+++ b/include/tools/link.hxx
@@ -102,6 +102,7 @@ public:
     { return function_ == other.function_ && instance_ == other.instance_; };
 
     void *GetInstance() const { return instance_; }
+    Stub* GetFunction() const { return function_; }
 
 private:
     Stub * function_;
diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx
index f50e329..b2834d4 100644
--- a/include/vcl/idle.hxx
+++ b/include/vcl/idle.hxx
@@ -20,34 +20,46 @@
 #ifndef INCLUDED_VCL_IDLE_HXX
 #define INCLUDED_VCL_IDLE_HXX
 
-#include <tools/link.hxx>
-#include <vcl/scheduler.hxx>
+#include <vcl/timer.hxx>
 
-class VCL_DLLPUBLIC Idle : public Scheduler
+/**
+ * An idle is a low priority timer to be scheduled immediately.
+ *
+ * Therefore the timeout is set to ImmediateTimeoutMs and the initial,
+ * priority is DEFAULT_IDLE.
+ *
+ * It's - more or less - just a convenience class.
+ */
+class VCL_DLLPUBLIC Idle : public Timer
 {
-protected:
-    Link<Idle *, void> maIdleHdl;          // Callback Link
-    bool               mbAuto;
-
-    virtual void SetDeletionFlags() override;
+private:
+    // Delete all timeout specific functions, we don't want in an Idle
+    void          SetTimeout( sal_uInt64 nTimeoutMs ) = delete;
+    sal_uInt64    GetTimeout() const = delete;
 
+protected:
     virtual bool ReadyForSchedule( const sal_uInt64 nTime ) const override;
     virtual void UpdateMinPeriod( const sal_uInt64 nTime, sal_uInt64 &nMinPeriod ) const override;
 
 public:
     Idle( const sal_Char *pDebugName = nullptr );
-    Idle( const Idle& rIdle );
 
-    virtual void    Start() override;
+    virtual void  Start() override;
 
-    /// Make it possible to associate a callback with this idle handler
-    /// of course, you can also sub-class and override 'Invoke'
-    void            SetIdleHdl( const Link<Idle *, void>& rLink ) { maIdleHdl = rLink; }
-    const Link<Idle *, void>& GetIdleHdl() const { return maIdleHdl; }
-    virtual void Invoke() override;
-    Idle&           operator=( const Idle& rIdle );
+    /**
+     * Convenience function for more readable code
+     *
+     * TODO: actually rename it and it's instances to SetInvokeHandler
+     */
+    inline void   SetIdleHdl( const Link<Idle *, void>& rLink );
 };
 
+inline void Idle::SetIdleHdl( const Link<Idle*, void> &rLink )
+{
+    SetInvokeHandler( Link<Timer*, void>( rLink.GetInstance(),
+        reinterpret_cast< Link<Timer*, void>::Stub* >( rLink.GetFunction()) ) );
+}
+
 /**
  * An auto-idle is long running task processing small chunks of data, which
  * is re-scheduled multiple times.
@@ -61,8 +73,6 @@ class VCL_DLLPUBLIC AutoIdle : public Idle
 {
 public:
     AutoIdle( const sal_Char *pDebugName = nullptr );
-    AutoIdle( const AutoIdle& rIdle );
-    AutoIdle& operator=( const AutoIdle& rIdle );
 };
 
 #endif // INCLUDED_VCL_IDLE_HXX
diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index 4f7e3d8..2cfa96a 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -26,9 +26,9 @@
 class VCL_DLLPUBLIC Timer : public Scheduler
 {
 protected:
-    Link<Timer *, void> maTimeoutHdl;          // Callback Link
-    sal_uInt64      mnTimeout;
-    bool            mbAuto;
+    Link<Timer *, void> maInvokeHandler;   ///< Callback Link
+    sal_uInt64          mnTimeout;
+    bool                mbAuto;
 
     virtual void SetDeletionFlags() override;
 
@@ -37,29 +37,45 @@ protected:
 
 public:
     Timer( const sal_Char *pDebugName = nullptr );
-    Timer( const Timer& rTimer );
 
-    /// Make it possible to associate a callback with this timer handler
-    /// of course, you can also sub-class and override 'Invoke'
-    void            SetTimeoutHdl( const Link<Timer *, void>& rLink ) { maTimeoutHdl = rLink; }
-    const Link<Timer *, void>& GetTimeoutHdl() const { return maTimeoutHdl; }
+    /**
+     * Calls the maInvokeHandler with the parameter this.
+     */
+    virtual void    Invoke() override;
+    /**
+     * Calls the maInvokeHandler with the parameter.
+     *
+     * Convenience Invoke function, mainly used to call with nullptr.
+     *
+     * @param arg parameter for the Link::Call function
+     */
+    void            Invoke( Timer *arg );
+    void            SetInvokeHandler( const Link<Timer *, void>& rLink ) { maInvokeHandler = rLink; }
+    bool            HasInvokeHandler() const { return maInvokeHandler.IsSet(); };
+
+    /**
+     * Convenience function for more readable code
+     *
+     * TODO: actually use SetInvokeHandler and drop it
+     */
+    inline void     SetTimeoutHdl( const Link<Timer *, void>& rLink );
+
     void            SetTimeout( sal_uInt64 nTimeoutMs );
     sal_uInt64      GetTimeout() const { return mnTimeout; }
-    virtual void    Invoke() override;
-    void            Timeout() { Invoke(); }
-    Timer&          operator=( const Timer& rTimer );
     virtual void    Start() override;
 };
 
+inline void Timer::SetTimeoutHdl( const Link<Timer *, void>& rLink )
+{
+    SetInvokeHandler( rLink );
+}
+
 /// An auto-timer is a multi-shot timer re-emitting itself at
 /// interval until destroyed.
 class VCL_DLLPUBLIC AutoTimer : public Timer
 {
 public:
-                    AutoTimer();
-                    AutoTimer( const AutoTimer& rTimer );
-
-    AutoTimer&      operator=( const AutoTimer& rTimer );
+    AutoTimer( const sal_Char *pDebugName = nullptr );
 };
 
 #endif // INCLUDED_VCL_TIMER_HXX
diff --git a/sc/source/core/tool/refreshtimer.cxx b/sc/source/core/tool/refreshtimer.cxx
index cb83c4c..954c132 100644
--- a/sc/source/core/tool/refreshtimer.cxx
+++ b/sc/source/core/tool/refreshtimer.cxx
@@ -120,7 +120,7 @@ void ScRefreshTimer::Invoke()
     {
         // now we COULD make the call in another thread ...
         ::osl::MutexGuard aGuard( (*ppControl)->GetMutex() );
-        maTimeoutHdl.Call( this );
+        Timer::Invoke();
         // restart from now on, don't execute immediately again if timed out
         // a second time during refresh
         if ( IsActive() )
diff --git a/solenv/gdb/libreoffice/vcl.py b/solenv/gdb/libreoffice/vcl.py
index 76ca27c..c7b4bf3 100644
--- a/solenv/gdb/libreoffice/vcl.py
+++ b/solenv/gdb/libreoffice/vcl.py
@@ -27,10 +27,11 @@ class ImplSchedulerDataPrinter(object):
     def as_string(self, gdbobj):
         if gdbobj['mpScheduler']:
             sched = gdbobj['mpScheduler'].dereference()
-            if gdbobj['mpScheduler'].dynamic_cast( self.timer_type_ptr ):
-                sched_type = "Timer"
-            elif gdbobj['mpScheduler'].dynamic_cast( self.idle_type_ptr ):
+            timer = gdbobj['mpScheduler'].dynamic_cast( self.timer_type_ptr )
+            if gdbobj['mpScheduler'].dynamic_cast( self.idle_type_ptr ):
                 sched_type = "Idle"
+            elif timer:
+                sched_type = "Timer"
             else:
                 assert sched_type, "Scheduler object neither Timer nor Idle"
             res = "{:7s}{:10s}".format( sched_type, str(sched['mePriority']) )
@@ -39,6 +40,12 @@ class ImplSchedulerDataPrinter(object):
                 res = "{}   (scheduler debug name not set) ({})".format(res, str(sched.dynamic_type))
             else:
                 res = "{} '{}' ({})".format(res, str(name.string()), str(sched.dynamic_type))
+            val_type = gdb.lookup_type(str( sched.dynamic_type )).pointer()
+            timer = gdbobj['mpScheduler'].cast( val_type )
+            if (sched_type == "Timer"):
+                res = "{}: {}ms".format(res, timer['mnTimeout'])
+            else:
+                assert 0 == timer['mnTimeout'], "Idle with timeout == {}".format( timer['mnTimeout'] )
             return res
         else:
             return "(no scheduler - to be deleted)"
diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx
index 5224c77..f2c6264 100644
--- a/vcl/source/app/idle.cxx
+++ b/vcl/source/app/idle.cxx
@@ -20,42 +20,15 @@
 #include <vcl/idle.hxx>
 #include "saltimer.hxx"
 
-void Idle::SetDeletionFlags()
-{
-    // If no AutoIdle, then stop.
-    if ( !mbAuto )
-        Scheduler::SetDeletionFlags();
-}
-
-void Idle::Invoke()
-{
-    maIdleHdl.Call( this );
-}
-
-Idle& Idle::operator=( const Idle& rIdle )
-{
-    Scheduler::operator=(rIdle);
-    maIdleHdl = rIdle.maIdleHdl;
-    mbAuto = rIdle.mbAuto;
-    return *this;
-}
-
 Idle::Idle( const sal_Char *pDebugName )
-    : Scheduler( pDebugName )
-    , mbAuto( false )
+    : Timer( pDebugName )
 {
     mePriority = SchedulerPriority::DEFAULT_IDLE;
 }
 
-Idle::Idle( const Idle& rIdle ) : Scheduler(rIdle)
-{
-    maIdleHdl = rIdle.maIdleHdl;
-    mbAuto = rIdle.mbAuto;
-}
-
 void Idle::Start()
 {
-    Scheduler::Start();
+    Timer::Start();
 
     sal_uInt64 nPeriod = Scheduler::ImmediateTimeoutMs;
     if (Scheduler::GetDeterministicMode())
@@ -88,17 +61,7 @@ void Idle::UpdateMinPeriod( const sal_uInt64 /* nTime */, sal_uInt64 &nMinPeriod
 AutoIdle::AutoIdle( const sal_Char *pDebugName )
     : Idle( pDebugName )
 {
-}
-
-AutoIdle::AutoIdle( const AutoIdle& rIdle ) : Idle( rIdle )
-{
     mbAuto = true;
 }
 
-AutoIdle& AutoIdle::operator=( const AutoIdle& rIdle )
-{
-    Idle::operator=( rIdle );
-    return *this;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 8a30fe1..8e02235 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -46,25 +46,22 @@ void Timer::UpdateMinPeriod( const sal_uInt64 nTime, sal_uInt64 &nMinPeriod ) co
     }
 }
 
-Timer::Timer(const sal_Char *pDebugName) :
-    Scheduler(pDebugName),
-    mnTimeout(ImmediateTimeoutMs),
-    mbAuto(false)
+Timer::Timer(const sal_Char *pDebugName)
+    : Scheduler( pDebugName )
+    , mnTimeout( ImmediateTimeoutMs )
+    , mbAuto( false )
 {
     mePriority = SchedulerPriority::DEFAULT;
 }
 
-Timer::Timer( const Timer& rTimer ) :
-    Scheduler(rTimer),
-    mnTimeout(rTimer.mnTimeout),
-    mbAuto(rTimer.mbAuto)
+void Timer::Invoke()
 {
-    maTimeoutHdl = rTimer.maTimeoutHdl;
+    maInvokeHandler.Call( this );
 }
 
-void Timer::Invoke()
+void Timer::Invoke( Timer *arg )
 {
-    maTimeoutHdl.Call( this );
+    maInvokeHandler.Call( arg );
 }
 
 void Timer::Start()
@@ -83,28 +80,10 @@ void Timer::SetTimeout( sal_uInt64 nNewTimeout )
     }
 }
 
-Timer& Timer::operator=( const Timer& rTimer )
-{
-    Scheduler::operator=(rTimer);
-    maTimeoutHdl = rTimer.maTimeoutHdl;
-    mnTimeout = rTimer.mnTimeout;
-    mbAuto = rTimer.mbAuto;
-    return *this;
-}
-
-AutoTimer::AutoTimer()
+AutoTimer::AutoTimer( const sal_Char *pDebugName )
+    : Timer( pDebugName )
 {
     mbAuto = true;
 }
 
-AutoTimer::AutoTimer( const AutoTimer& rTimer ) : Timer( rTimer )
-{
-    mbAuto = true;
-}
-
-AutoTimer& AutoTimer::operator=( const AutoTimer& rTimer )
-{
-    Timer::operator=( rTimer );
-    return *this;
-}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index dddb4ff..0973a58 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -1923,7 +1923,7 @@ void Edit::LoseFocus()
     {
         //notify an update latest when the focus is lost
         mpUpdateDataTimer->Stop();
-        mpUpdateDataTimer->Timeout();
+        mpUpdateDataTimer->Invoke();
     }
 
     if ( !mpSubEdit )
diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx
index c732314..02378b2 100644
--- a/vcl/source/edit/textdata.cxx
+++ b/vcl/source/edit/textdata.cxx
@@ -293,7 +293,7 @@ void IdleFormatter::DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts )
     if ( mnRestarts > nMaxRestarts )
     {
         mnRestarts = 0;
-        ((Link<Idle *, void>&)GetIdleHdl()).Call( this );
+        Invoke();
     }
     else
     {
@@ -307,7 +307,7 @@ void IdleFormatter::ForceTimeout()
     {
         Stop();
         mnRestarts = 0;
-        ((Link<Idle *, void>&)GetIdleHdl()).Call( this );
+        Invoke();
     }
 }
 
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index af0896c..2d23020 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -673,7 +673,7 @@ IMPL_LINK_NOARG(Window, ImplHandleResizeTimerHdl, Idle *, void)
         if( mpWindowImpl->mpFrameData->maPaintIdle.IsActive() )
         {
             mpWindowImpl->mpFrameData->maPaintIdle.Stop();
-            mpWindowImpl->mpFrameData->maPaintIdle.GetIdleHdl().Call( nullptr );
+            mpWindowImpl->mpFrameData->maPaintIdle.Invoke( nullptr );
         }
     }
 }
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 8db7645..3db6ee8 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -2395,7 +2395,7 @@ Size Window::GetSizePixel() const
     {
         VclPtr<vcl::Window> xWindow( const_cast<Window*>(this) );
         mpWindowImpl->mpFrameData->maResizeIdle.Stop();
-        mpWindowImpl->mpFrameData->maResizeIdle.GetIdleHdl().Call( nullptr );
+        mpWindowImpl->mpFrameData->maResizeIdle.Invoke( nullptr );
         if( xWindow->IsDisposed() )
             return Size(0,0);
     }
commit a7987ca1a6d81c5c489b683cdffecef7ee7f65e3
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Mon Sep 12 18:24:14 2016 +0200

    Handle all main loop and task events
    
    Change-Id: I75ed5a38b0e24966dafcfdd2ea4cb8afc93a8a0c

diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 11dcadc..4ff2181 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -502,7 +502,14 @@ inline bool ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
     if (nReleased == 0) // tdf#99383 don't run stuff from ReAcquireSolarMutex
     {
         // Process all Tasks
-        bProcessedEvent = Scheduler::ProcessTaskScheduling() || bProcessedEvent;
+        do
+        {
+            bool bScheduledEevent = Scheduler::ProcessTaskScheduling();
+            bProcessedEvent |= bScheduledEevent;
+            if (!bScheduledEevent)
+                break;
+        }
+        while ( i_bAllEvents );
     }
 
     // flush lazy deleted objects
commit 79e0d33b23bffb6e6decb588ec58b55426be9be9
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Wed Aug 10 12:00:53 2016 +0200

    Reorganize Scheduler priority classes
    
    This is based on glibs classification of tasks, but while glib uses
    an int for more fine grained priority, we stay with our enum.
    
    1. Timers start with DEFAULT priority, which directly corresponds
       with the previous HIGH priority
    2. Idles start with DEFAULT_IDLE priority instead of the previous
       HIGH priority, so idle default becomes "really run when idle".
    
    As RESIZE and REPAINT are special, and the DEFAULTS are set, there
    is just one primary decision for the programmer: should my idle
    run before paint (AKA HIGH_IDLE)?
    
    If we really need a more fine-grained classification, we can add it
    later, or also switch to a real int. As a result, this drops many
    classifications from the code and drastically changes behaviour,
    AKA a mail merge from KDE is now as fast as Gtk+ again.
    
    Change-Id: I498a73fd02d5fb6f5d7e9f742f3bce972de9b1f9

diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx
index 872abab..32d5154 100644
--- a/avmedia/source/framework/mediacontrol.cxx
+++ b/avmedia/source/framework/mediacontrol.cxx
@@ -114,7 +114,7 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl
         mpZoomToolBox->SetPaintTransparent( true );
     }
 
-    maIdle.SetPriority( SchedulerPriority::LOW );
+    maIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
     maIdle.SetIdleHdl( LINK( this, MediaControl, implTimeoutHdl ) );
     maIdle.Start();
 }
diff --git a/avmedia/source/framework/soundhandler.cxx b/avmedia/source/framework/soundhandler.cxx
index 753fddc..ece9df4 100644
--- a/avmedia/source/framework/soundhandler.cxx
+++ b/avmedia/source/framework/soundhandler.cxx
@@ -221,7 +221,7 @@ void SAL_CALL SoundHandler::dispatchWithNotification(const css::util::URL&
         // Count this request and initialize self-holder against dying by uno ref count ...
         m_xSelfHold.set(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
         m_xPlayer->start();
-        m_aUpdateIdle.SetPriority( SchedulerPriority::LOWER );
+        m_aUpdateIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
         m_aUpdateIdle.Start();
     }
     catch( css::uno::Exception& e )
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index 50fdf4c..4991758 100644
--- a/avmedia/source/opengl/oglplayer.cxx
+++ b/avmedia/source/opengl/oglplayer.cxx
@@ -123,7 +123,7 @@ bool OGLPlayer::create( const OUString& rURL )
 
     // Set timer
     m_aTimer.SetTimeout(8); // is 125fps enough for anyone ?
-    m_aTimer.SetPriority(SchedulerPriority::LOW);
+    m_aTimer.SetPriority(SchedulerPriority::HIGH_IDLE);
     m_aTimer.SetTimeoutHdl(LINK(this,OGLPlayer,TimerHandler));
 
     return true;
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 64003b6..9892435 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -961,7 +961,6 @@ void EditorWindow::CreateEditEngine()
 
     ImplSetFont();
 
-    aSyntaxIdle.SetPriority( SchedulerPriority::LOWER );
     aSyntaxIdle.SetIdleHdl( LINK( this, EditorWindow, SyntaxTimerHdl ) );
 
     bool bWasDoSyntaxHighlight = bDoSyntaxHighlight;
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index 09fb336..8ca7500 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -218,7 +218,6 @@ DlgEditor::DlgEditor (
     m_ClipboardDataFlavorsResource[1].HumanPresentableName = "Dialog 8.0" ;
     m_ClipboardDataFlavorsResource[1].DataType =             cppu::UnoType<Sequence< sal_Int8 >>::get();
 
-    aMarkIdle.SetPriority(SchedulerPriority::LOW);
     aMarkIdle.SetIdleHdl( LINK( this, DlgEditor, MarkTimeout ) );
 
     rWindow.SetMapMode( MapMode( MapUnit::Map100thMM ) );
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index c8bb0cb..8d28ac8 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -186,7 +186,6 @@ SvxJavaOptionsPage::SvxJavaOptionsPage( vcl::Window* pParent, const SfxItemSet&
     m_pParameterBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ParameterHdl_Impl ) );
     m_pClassPathBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ClassPathHdl_Impl ) );
     m_aResetIdle.SetIdleHdl( LINK( this, SvxJavaOptionsPage, ResetHdl_Impl ) );
-    m_aResetIdle.SetPriority(SchedulerPriority::LOWER);
 
     m_pExpertConfigBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ExpertConfigHdl_Impl) );
     if (!officecfg::Office::Common::Security::EnableExpertConfiguration::get())
diff --git a/cui/source/tabpages/macroass.cxx b/cui/source/tabpages/macroass.cxx
index af0c0bd..7a73d76 100644
--- a/cui/source/tabpages/macroass.cxx
+++ b/cui/source/tabpages/macroass.cxx
@@ -138,7 +138,7 @@ SfxMacroTabPage::SfxMacroTabPage(vcl::Window* pParent, const Reference< XFrame >
     mpImpl.reset(new SfxMacroTabPage_Impl);
 
     mpImpl->maFillGroupIdle.SetIdleHdl( LINK( this, SfxMacroTabPage, TimeOut_Impl ) );
-    mpImpl->maFillGroupIdle.SetPriority( SchedulerPriority::HIGHEST );
+    mpImpl->maFillGroupIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
     mpImpl->maFillGroupIdle.SetDebugName( "SfxMacroTabPage maFillGroupIdle" );
 
     mpImpl->sStrEvent = get<FixedText>("eventft")->GetText();
diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx
index 52d2de8..07e2bb4 100644
--- a/dbaccess/source/ui/querydesign/JoinTableView.cxx
+++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx
@@ -1063,7 +1063,7 @@ void OJoinTableView::ScrollWhileDragging()
     // resetting timer, if still necessary
     if (bNeedScrollTimer)
     {
-        m_aDragScrollIdle.SetPriority(SchedulerPriority::LOW);
+        m_aDragScrollIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
         m_aDragScrollIdle.Start();
     }
 
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index c753015..077d78f 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -1214,7 +1214,6 @@ UpdateRequiredDialog::UpdateRequiredDialog(vcl::Window *pParent, TheExtensionMan
     m_pUpdateBtn->Enable( false );
     m_pCloseBtn->GrabFocus();
 
-    m_aIdle.SetPriority( SchedulerPriority::LOWEST );
     m_aIdle.SetIdleHdl( LINK( this, UpdateRequiredDialog, TimeOutHdl ) );
 }
 
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 4947a36..a1a4af8 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -1802,7 +1802,6 @@ OUString FormulaDlg::GetMeText() const
 void FormulaDlg::Update()
 {
     m_pImpl->Update();
-    m_pImpl->aIdle.SetPriority(SchedulerPriority::LOWER);
     m_pImpl->aIdle.SetIdleHdl(LINK( this, FormulaDlg, UpdateFocusHdl));
     m_pImpl->aIdle.Start();
 }
diff --git a/formula/source/ui/dlg/funcutl.cxx b/formula/source/ui/dlg/funcutl.cxx
index f1f014c..36687fc 100644
--- a/formula/source/ui/dlg/funcutl.cxx
+++ b/formula/source/ui/dlg/funcutl.cxx
@@ -435,7 +435,6 @@ RefEdit::RefEdit( vcl::Window* _pParent, vcl::Window* pShrinkModeLabel, WinBits
     , pLabelWidget(pShrinkModeLabel)
 {
     aIdle.SetIdleHdl( LINK( this, RefEdit, UpdateHdl ) );
-    aIdle.SetPriority( SchedulerPriority::LOW );
 }
 
 RefEdit::RefEdit( vcl::Window* _pParent,IControlReferenceHandler* pParent,
@@ -446,7 +445,6 @@ RefEdit::RefEdit( vcl::Window* _pParent,IControlReferenceHandler* pParent,
     , pLabelWidget(pShrinkModeLabel)
 {
     aIdle.SetIdleHdl( LINK( this, RefEdit, UpdateHdl ) );
-    aIdle.SetPriority( SchedulerPriority::LOW );
 }
 
 VCL_BUILDER_DECL_FACTORY(RefEdit)
@@ -515,7 +513,6 @@ void RefEdit::SetReferences( IControlReferenceHandler* pDlg, vcl::Window* pLabel
     if( pDlg )
     {
         aIdle.SetIdleHdl( LINK( this, RefEdit, UpdateHdl ) );
-        aIdle.SetPriority( SchedulerPriority::LOW );
     }
     else
     {
diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index 69684b3..3d4fde6 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -25,17 +25,16 @@
 struct ImplSchedulerData;
 struct ImplSVData;
 
-enum class SchedulerPriority {
-    HIGHEST      = 0,
-    HIGH         = 1,
-    RESIZE       = 2,
-    REPAINT      = 3,
-    MEDIUM       = 3,
-    POST_PAINT   = 4,
-    DEFAULT_IDLE = 5,
-    LOW          = 6,
-    LOWER        = 7,
-    LOWEST       = 8
+enum class SchedulerPriority
+{
+    HIGHEST,       ///< These events should run very fast!
+    DEFAULT,       ///< Default priority used, e.g. the default timer priority
+    HIGH_IDLE,     ///< Important idle events to be run before processing drawing events
+    RESIZE,        ///< Resize runs before repaint, so we won't paint twice
+    REPAINT,       ///< All repaint events should go in here
+    POST_PAINT,    ///< Everything running directly after painting
+    DEFAULT_IDLE,  ///< Default idle priority
+    LOWEST         ///< Low, very idle cleanup tasks
 };
 
 class VCL_DLLPUBLIC Scheduler
diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx
index 6b21aec..4ae321e 100644
--- a/reportdesign/source/ui/report/DesignView.cxx
+++ b/reportdesign/source/ui/report/DesignView.cxx
@@ -117,7 +117,6 @@ ODesignView::ODesignView(   vcl::Window* pParent,
     m_aSplitWin->SetAlign(WindowAlign::Left);
     m_aSplitWin->Show();
 
-    m_aMarkIdle.SetPriority( SchedulerPriority::LOW );
     m_aMarkIdle.SetIdleHdl( LINK( this, ODesignView, MarkTimeout ) );
 }
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index d2af6d2..c6fbcee 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -249,7 +249,6 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) :
     SetLanguage( ScGlobal::eLnge, ScGlobal::eLnge, ScGlobal::eLnge );
 
     aTrackIdle.SetIdleHdl( LINK( this, ScDocument, TrackTimeHdl ) );
-    aTrackIdle.SetPriority( SchedulerPriority::LOW );
 }
 
 sfx2::LinkManager* ScDocument::GetLinkManager()
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 356edd1..f84f3da 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -177,7 +177,6 @@ ScModule::ScModule( SfxObjectFactory* pFact ) :
                                         ERRCODE_AREA_APP2-1,
                                         GetResMgr() );
 
-    aSpellIdle.SetPriority(SchedulerPriority::LOWER);
     aSpellIdle.SetIdleHdl( LINK( this, ScModule, SpellTimerHdl ) );
     aSpellIdle.SetDebugName( "sc::ScModule aSpellIdle" );
 
diff --git a/sc/source/ui/docshell/autostyl.cxx b/sc/source/ui/docshell/autostyl.cxx
index 3888dbc..5a59827 100644
--- a/sc/source/ui/docshell/autostyl.cxx
+++ b/sc/source/ui/docshell/autostyl.cxx
@@ -65,7 +65,7 @@ ScAutoStyleList::ScAutoStyleList(ScDocShell* pShell)
 {
     aTimer.SetTimeoutHdl( LINK( this, ScAutoStyleList, TimerHdl ) );
     aInitIdle.SetIdleHdl( LINK( this, ScAutoStyleList, InitHdl ) );
-    aInitIdle.SetPriority( SchedulerPriority::HIGHEST );
+    aInitIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
 }
 
 ScAutoStyleList::~ScAutoStyleList()
diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx
index 11f9ab7..a3fb616 100644
--- a/sc/source/ui/formdlg/dwfunctr.cxx
+++ b/sc/source/ui/formdlg/dwfunctr.cxx
@@ -70,7 +70,6 @@ ScFunctionWin::ScFunctionWin( SfxBindings* pBindingsP, vcl::Window* pParent, con
     InitLRUList();
     SetStyle(GetStyle()|WB_CLIPCHILDREN);
 
-    aIdle.SetPriority(SchedulerPriority::LOWER);
     aIdle.SetIdleHdl(LINK( this, ScFunctionWin, TimerHdl));
 
     aFiFuncDesc->SetUpdateMode(true);
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
index 2bbcb8c..5c93ef3 100644
--- a/sc/source/ui/miscdlgs/acredlin.cxx
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -108,13 +108,11 @@ ScAcceptChgDlg::ScAcceptChgDlg(SfxBindings* pB, SfxChildWindow* pCW, vcl::Window
     m_pAcceptChgCtr = VclPtr<SvxAcceptChgCtr>::Create(get_content_area(), this);
     nAcceptCount=0;
     nRejectCount=0;
-    aReOpenIdle.SetPriority(SchedulerPriority::MEDIUM);
     aReOpenIdle.SetIdleHdl(LINK( this, ScAcceptChgDlg, ReOpenTimerHdl ));
 
     pTPFilter=m_pAcceptChgCtr->GetFilterPage();
     pTPView=m_pAcceptChgCtr->GetViewPage();
     pTheView=pTPView->GetTableControl();
-    aSelectionIdle.SetPriority(SchedulerPriority::LOW);
     aSelectionIdle.SetIdleHdl(LINK( this, ScAcceptChgDlg, UpdateSelectionHdl ));
     aSelectionIdle.SetDebugName( "ScAcceptChgDlg  aSelectionIdle" );
 
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 532cf9c..965ee98 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -765,7 +765,6 @@ ScRefHandler::ScRefHandler( vcl::Window &rWindow, SfxBindings* pB, bool bBindRef
         pActiveWin(nullptr)
 {
     m_aHelper.SetWindow(m_rWindow.get());
-    aIdle.SetPriority(SchedulerPriority::LOWER);
     aIdle.SetIdleHdl(LINK( this, ScRefHandler, UpdateFocusHdl));
 
     if( bBindRef ) EnterRefMode();
diff --git a/sc/source/ui/miscdlgs/conflictsdlg.cxx b/sc/source/ui/miscdlgs/conflictsdlg.cxx
index 578efed..73f740c 100644
--- a/sc/source/ui/miscdlgs/conflictsdlg.cxx
+++ b/sc/source/ui/miscdlgs/conflictsdlg.cxx
@@ -421,7 +421,6 @@ ScConflictsDlg::ScConflictsDlg( vcl::Window* pParent, ScViewData* pViewData, ScD
     m_pLbConflicts->SetSelectionMode( SelectionMode::Multiple );
     m_pLbConflicts->SetHighlightRange();
 
-    maSelectionIdle.SetPriority( SchedulerPriority::LOW );
     maSelectionIdle.SetIdleHdl( LINK( this, ScConflictsDlg, UpdateSelectionHdl ) );
     maSelectionIdle.SetDebugName( "ScConflictsDlg maSelectionIdle" );
 
diff --git a/sd/source/ui/dlg/filedlg.cxx b/sd/source/ui/dlg/filedlg.cxx
index b06c780..ad78df5 100644
--- a/sd/source/ui/dlg/filedlg.cxx
+++ b/sd/source/ui/dlg/filedlg.cxx
@@ -129,7 +129,6 @@ IMPL_LINK_NOARG(SdFileDialog_Imp, PlayMusicHdl, void*, void)
             {
                 mxPlayer.set( avmedia::MediaWindow::createPlayer( aUrl, "" ), css::uno::UNO_QUERY_THROW );
                 mxPlayer->start();
-                maUpdateIdle.SetPriority( SchedulerPriority::LOW );
                 maUpdateIdle.Start();
             }
             catch (const css::uno::Exception&)
diff --git a/sd/source/ui/framework/module/ShellStackGuard.cxx b/sd/source/ui/framework/module/ShellStackGuard.cxx
index cf4fe2d..37bcde4 100644
--- a/sd/source/ui/framework/module/ShellStackGuard.cxx
+++ b/sd/source/ui/framework/module/ShellStackGuard.cxx
@@ -72,7 +72,6 @@ ShellStackGuard::ShellStackGuard (Reference<frame::XController>& rxController)
 
         // Prepare the printer polling.
         maPrinterPollingIdle.SetIdleHdl(LINK(this,ShellStackGuard,TimeoutHandler));
-        maPrinterPollingIdle.SetPriority(SchedulerPriority::LOWER);
     }
 }
 
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx
index 1838126..8a98fcc 100644
--- a/sd/source/ui/view/sdview.cxx
+++ b/sd/source/ui/view/sdview.cxx
@@ -143,9 +143,7 @@ View::View(SdDrawDocument& rDrawDoc, OutputDevice* pOutDev,
 
     // Timer for delayed drop (has to be for MAC)
     maDropErrorIdle.SetIdleHdl( LINK(this, View, DropErrorHdl) );
-    maDropErrorIdle.SetPriority(SchedulerPriority::MEDIUM);
     maDropInsertFileIdle.SetIdleHdl( LINK(this, View, DropInsertFileHdl) );
-    maDropInsertFileIdle.SetPriority(SchedulerPriority::MEDIUM);
 }
 
 void View::ImplClearDrawDropMarker()
diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx
index c170a65..c7283b2 100644
--- a/sfx2/source/appl/appcfg.cxx
+++ b/sfx2/source/appl/appcfg.cxx
@@ -110,7 +110,7 @@ SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint& rHint )
         StartListening( *rHint.GetObjShell() );
     pIdle = new Idle("SfxEventASyncer");
     pIdle->SetIdleHdl( LINK(this, SfxEventAsyncer_Impl, IdleHdl) );
-    pIdle->SetPriority( SchedulerPriority::HIGHEST );
+    pIdle->SetPriority( SchedulerPriority::HIGH_IDLE );
     pIdle->SetDebugName( "sfx::SfxEventAsyncer_Impl pIdle" );
     pIdle->Start();
 }
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 9735cb2..e1a1a94 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -553,7 +553,6 @@ IndexTabPage_Impl::IndexTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_Im
     m_pOpenBtn->SetClickHdl( LINK( this, IndexTabPage_Impl, OpenHdl ) );
     Link<Timer *, void> aTimeoutLink = LINK( this, IndexTabPage_Impl, TimeoutHdl );
     aFactoryIdle.SetIdleHdl( LINK(this, IndexTabPage_Impl, IdleHdl ));
-    aFactoryIdle.SetPriority(SchedulerPriority::LOWER);
     aKeywordTimer.SetTimeoutHdl( aTimeoutLink );
 }
 
@@ -1433,7 +1432,6 @@ SfxHelpIndexWindow_Impl::SfxHelpIndexWindow_Impl(SfxHelpWindow_Impl* _pParent)
     nMinWidth = ( m_pActiveLB->GetSizePixel().Width() / 2 );
 
     aIdle.SetIdleHdl( LINK( this, SfxHelpIndexWindow_Impl, InitHdl ) );
-    aIdle.SetPriority( SchedulerPriority::LOWER );
     aIdle.Start();
 
     Show();
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 0b10e0a..c625e29 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -449,7 +449,7 @@ void SfxDispatcher::Construct_Impl( SfxDispatcher* pParent )
 
     xImp->xPoster = new SfxHintPoster(aGenLink);
 
-    xImp->aIdle.SetPriority(SchedulerPriority::MEDIUM);
+    xImp->aIdle.SetPriority(SchedulerPriority::HIGH_IDLE );
     xImp->aIdle.SetIdleHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) );
     xImp->aIdle.SetDebugName( "sfx::SfxDispatcher_Impl aIdle" );
 }
@@ -586,8 +586,6 @@ void SfxDispatcher::Pop(SfxShell& rShell, SfxDispatcherPopFlags nMode)
     if(!pSfxApp->IsDowning() && !xImp->aToDoStack.empty())
     {
         // No immediate update is requested
-        xImp->aIdle.SetPriority(SchedulerPriority::MEDIUM);
-        xImp->aIdle.SetIdleHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) );
         xImp->aIdle.Start();
     }
     else
@@ -789,8 +787,6 @@ void SfxDispatcher::DoActivate_Impl(bool bMDI)
     if(!xImp->aToDoStack.empty())
     {
         // No immediate update is requested
-        xImp->aIdle.SetPriority(SchedulerPriority::MEDIUM);
-        xImp->aIdle.SetIdleHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) );
         xImp->aIdle.Start();
     }
 }
diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx
index c8811c8..5d489b6 100644
--- a/svtools/source/contnr/imivctl1.cxx
+++ b/svtools/source/contnr/imivctl1.cxx
@@ -143,7 +143,7 @@ SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl(
     aEditIdle.SetIdleHdl(LINK(this,SvxIconChoiceCtrl_Impl,EditTimeoutHdl));
     aEditIdle.SetDebugName( "svtools::SvxIconChoiceCtrl_Impl aEditIdle" );
 
-    aAutoArrangeIdle.SetPriority( SchedulerPriority::LOW );
+    aAutoArrangeIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
     aAutoArrangeIdle.SetIdleHdl(LINK(this,SvxIconChoiceCtrl_Impl,AutoArrangeHdl));
     aAutoArrangeIdle.SetDebugName( "svtools::SvxIconChoiceCtrl_Impl aAutoArrangeIdle" );
 
@@ -151,11 +151,11 @@ SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl(
     aCallSelectHdlIdle.SetIdleHdl( LINK(this,SvxIconChoiceCtrl_Impl,CallSelectHdlHdl));
     aCallSelectHdlIdle.SetDebugName( "svtools::SvxIconChoiceCtrl_Impl aCallSelectHdlIdle" );
 
-    aDocRectChangedIdle.SetPriority( SchedulerPriority::MEDIUM );
+    aDocRectChangedIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
     aDocRectChangedIdle.SetIdleHdl(LINK(this,SvxIconChoiceCtrl_Impl,DocRectChangedHdl));
     aDocRectChangedIdle.SetDebugName( "svtools::SvxIconChoiceCtrl_Impl aDocRectChangedIdle" );
 
-    aVisRectChangedIdle.SetPriority( SchedulerPriority::MEDIUM );
+    aVisRectChangedIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
     aVisRectChangedIdle.SetIdleHdl(LINK(this,SvxIconChoiceCtrl_Impl,VisRectChangedHdl));
     aVisRectChangedIdle.SetDebugName( "svtools::SvxIconChoiceCtrl_Impl aVisRectChangedIdle" );
 
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index 605d227..9cf8b07e 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -89,7 +89,7 @@ SvImpLBox::SvImpLBox( SvTreeListBox* pLBView, SvTreeList* pLBTree, WinBits nWinS
     nNodeBmpWidth       = 0;
 
     bAsyncBeginDrag     = false;
-    aAsyncBeginDragIdle.SetPriority( SchedulerPriority::HIGHEST );
+    aAsyncBeginDragIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
     aAsyncBeginDragIdle.SetIdleHdl( LINK(this,SvImpLBox,BeginDragHdl));
     // button animation in listbox
     pActiveButton = nullptr;
diff --git a/svx/source/dialog/_contdlg.cxx b/svx/source/dialog/_contdlg.cxx
index 2f316de..e836eb9 100644
--- a/svx/source/dialog/_contdlg.cxx
+++ b/svx/source/dialog/_contdlg.cxx
@@ -286,7 +286,6 @@ SvxSuperContourDlg::SvxSuperContourDlg(SfxBindings *_pBindings, SfxChildWindow *
 
     Resize();
 
-    aUpdateIdle.SetPriority( SchedulerPriority::LOW );
     aUpdateIdle.SetIdleHdl( LINK( this, SvxSuperContourDlg, UpdateHdl ) );
 
     aCreateIdle.SetPriority( SchedulerPriority::RESIZE );
diff --git a/svx/source/dialog/imapdlg.cxx b/svx/source/dialog/imapdlg.cxx
index fb09fe6..c350f25 100644
--- a/svx/source/dialog/imapdlg.cxx
+++ b/svx/source/dialog/imapdlg.cxx
@@ -203,7 +203,6 @@ SvxIMapDlg::SvxIMapDlg(SfxBindings *_pBindings, SfxChildWindow *pCW, vcl::Window
     m_pCbbTarget->Disable();
     pOwnData->bExecState = false;
 
-    pOwnData->aIdle.SetPriority( SchedulerPriority::LOW );
     pOwnData->aIdle.SetIdleHdl( LINK( this, SvxIMapDlg, UpdateHdl ) );
 
     m_pTbxIMapDlg1->EnableItem( mnActiveId, false );
diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx
index efeaad6..57fdc7e 100644
--- a/svx/source/sdr/contact/objectcontactofpageview.cxx
+++ b/svx/source/sdr/contact/objectcontactofpageview.cxx
@@ -61,7 +61,7 @@ namespace sdr
             setPreviewRenderer(((SdrPaintView&)rPageWindow.GetPageView().GetView()).IsPreviewRenderer());
 
             // init timer
-            SetPriority(SchedulerPriority::HIGH);
+            SetPriority(SchedulerPriority::HIGH_IDLE);
             Stop();
         }
 
diff --git a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx
index 4827c3d..dc274cd 100644
--- a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx
@@ -84,7 +84,7 @@ PagePrimitiveExtractor::PagePrimitiveExtractor(
     setPreviewRenderer(true);
 
     // init timer
-    SetPriority(SchedulerPriority::HIGH);
+    SetPriority(SchedulerPriority::HIGH_IDLE);
     Stop();
 }
 
diff --git a/svx/source/sdr/event/eventhandler.cxx b/svx/source/sdr/event/eventhandler.cxx
index 681d9cf..4588972 100644
--- a/svx/source/sdr/event/eventhandler.cxx
+++ b/svx/source/sdr/event/eventhandler.cxx
@@ -83,7 +83,7 @@ namespace sdr
 
         TimerEventHandler::TimerEventHandler()
         {
-            SetPriority(SchedulerPriority::HIGH);
+            SetPriority(SchedulerPriority::HIGH_IDLE);
             Stop();
         }
 
diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx
index 44ab835..7247be0 100644
--- a/svx/source/svdraw/svdibrow.cxx
+++ b/svx/source/svdraw/svdibrow.cxx
@@ -1101,7 +1101,7 @@ void SdrItemBrowser::SetDirty()
 {
     if (!bDirty) {
         bDirty = true;
-        aIdle.SetPriority(SchedulerPriority::HIGH);
+        aIdle.SetPriority(SchedulerPriority::HIGH_IDLE);
         aIdle.Start();
     }
 }
diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx
index 22cc918..c07f10d 100644
--- a/svx/source/tbxctrls/grafctrl.cxx
+++ b/svx/source/tbxctrls/grafctrl.cxx
@@ -121,7 +121,6 @@ ImplGrafMetricField::ImplGrafMetricField( vcl::Window* pParent, const OUString&
         SetSpinSize( 1 );
     }
 
-    maIdle.SetPriority( SchedulerPriority::LOW );
     maIdle.SetIdleHdl( LINK( this, ImplGrafMetricField, ImplModifyHdl ) );
 }
 
diff --git a/sw/source/uibase/docvw/srcedtw.cxx b/sw/source/uibase/docvw/srcedtw.cxx
index 8f2e3bf..ec9a4b8 100644
--- a/sw/source/uibase/docvw/srcedtw.cxx
+++ b/sw/source/uibase/docvw/srcedtw.cxx
@@ -535,7 +535,6 @@ void SwSrcEditWindow::CreateTextEngine()
     m_pOutWin->SetFont( aFont );
     m_pTextEngine->SetFont( aFont );
 
-    m_aSyntaxIdle.SetPriority( SchedulerPriority::LOWER );
     m_aSyntaxIdle.SetIdleHdl( LINK( this, SwSrcEditWindow, SyntaxTimerHdl ) );
 
     m_pTextEngine->EnableUndo( true );
diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx
index 4a89a65..6b9bf20 100644
--- a/sw/source/uibase/utlui/unotools.cxx
+++ b/sw/source/uibase/utlui/unotools.cxx
@@ -84,7 +84,7 @@ SwOneExampleFrame::SwOneExampleFrame( vcl::Window& rWin,
 
     // the controller is asynchronously set
     aLoadedIdle.SetIdleHdl(LINK(this, SwOneExampleFrame, TimeoutHdl));
-    aLoadedIdle.SetPriority(SchedulerPriority::HIGH);
+    aLoadedIdle.SetPriority(SchedulerPriority::HIGH_IDLE);
 
     CreateControl();
 
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index 33a2fb4..3fcdcc8 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -105,7 +105,6 @@ void AquaSalInstance::delayedSettingsChanged( bool bInvalidate )
 {
     osl::Guard< comphelper::SolarMutex > aGuard( *mpSalYieldMutex );
     AquaDelayedSettingsChanged* pIdle = new AquaDelayedSettingsChanged( bInvalidate );
-    pIdle->SetPriority( SchedulerPriority::MEDIUM );
     pIdle->Start();
 }
 
diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx
index 1fe9819..5224c77 100644
--- a/vcl/source/app/idle.cxx
+++ b/vcl/source/app/idle.cxx
@@ -44,6 +44,7 @@ Idle::Idle( const sal_Char *pDebugName )
     : Scheduler( pDebugName )
     , mbAuto( false )
 {
+    mePriority = SchedulerPriority::DEFAULT_IDLE;
 }
 
 Idle::Idle( const Idle& rIdle ) : Scheduler(rIdle)
@@ -61,8 +62,7 @@ void Idle::Start()
     {
         switch (mePriority)
         {
-            case SchedulerPriority::LOW:
-            case SchedulerPriority::LOWER:
+            case SchedulerPriority::DEFAULT_IDLE:
             case SchedulerPriority::LOWEST:
                 nPeriod = Scheduler::InfiniteTimeoutMs;
                 break;
@@ -82,7 +82,7 @@ bool Idle::ReadyForSchedule( const sal_uInt64 /* nTime */ ) const
 
 void Idle::UpdateMinPeriod( const sal_uInt64 /* nTime */, sal_uInt64 &nMinPeriod ) const
 {
-    nMinPeriod = ImmediateTimeoutMs;
+    nMinPeriod = ImmediateTimeoutMs; // don't wait
 }
 
 AutoIdle::AutoIdle( const sal_Char *pDebugName )
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 0068a07..b1406b9 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -309,7 +309,7 @@ Scheduler& Scheduler::operator=( const Scheduler& rScheduler )
 Scheduler::Scheduler(const sal_Char *pDebugName):
     mpSchedulerData(nullptr),
     mpDebugName(pDebugName),
-    mePriority(SchedulerPriority::HIGH)
+    mePriority(SchedulerPriority::DEFAULT)
 {
 }
 
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 2cc424b..11dcadc 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -459,7 +459,7 @@ void Application::Execute()
         pSVData->maAppData.mnEventTestLimit = 50;
         pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting");
         pSVData->maAppData.mpEventTestingIdle->SetIdleHdl(LINK(&(pSVData->maAppData), ImplSVAppData, VclEventTestingHdl));
-        pSVData->maAppData.mpEventTestingIdle->SetPriority(SchedulerPriority::MEDIUM);
+        pSVData->maAppData.mpEventTestingIdle->SetPriority(SchedulerPriority::HIGH_IDLE);
         pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ);
         pSVData->maAppData.mpEventTestingIdle->Start();
     }
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index fb5d382..8a30fe1 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -51,7 +51,7 @@ Timer::Timer(const sal_Char *pDebugName) :
     mnTimeout(ImmediateTimeoutMs),
     mbAuto(false)
 {
-    mePriority = SchedulerPriority::HIGHEST;
+    mePriority = SchedulerPriority::DEFAULT;
 }
 
 Timer::Timer( const Timer& rTimer ) :
diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx
index 5a3b15c..c732314 100644
--- a/vcl/source/edit/textdata.cxx
+++ b/vcl/source/edit/textdata.cxx
@@ -275,7 +275,7 @@ IdleFormatter::IdleFormatter()
 {
     mpView = nullptr;
     mnRestarts = 0;
-    SetPriority(SchedulerPriority::HIGH);
+    SetPriority(SchedulerPriority::HIGH_IDLE);
 }
 
 IdleFormatter::~IdleFormatter()
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 560b6d4..6a6f3b2 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -88,11 +88,11 @@ ImplDockFloatWin2::ImplDockFloatWin2( vcl::Window* pParent, WinBits nWinBits,
     SetBackground( GetSettings().GetStyleSettings().GetFaceColor() );
 
     maDockIdle.SetIdleHdl( LINK( this, ImplDockFloatWin2, DockTimerHdl ) );
-    maDockIdle.SetPriority( SchedulerPriority::MEDIUM );
+    maDockIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
     maDockIdle.SetDebugName( "vcl::ImplDockFloatWin2 maDockIdle" );
 
     maEndDockIdle.SetIdleHdl( LINK( this, ImplDockFloatWin2, EndDockTimerHdl ) );
-    maEndDockIdle.SetPriority( SchedulerPriority::MEDIUM );
+    maEndDockIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
     maEndDockIdle.SetDebugName( "vcl::ImplDockFloatWin2 maEndDockIdle" );
 }
 
diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx
index 00c038b..f983cfc 100644
--- a/vcl/source/window/dockwin.cxx
+++ b/vcl/source/window/dockwin.cxx
@@ -103,7 +103,7 @@ ImplDockFloatWin::ImplDockFloatWin( vcl::Window* pParent, WinBits nWinBits,
     SetBackground();
 
     maDockIdle.SetIdleHdl( LINK( this, ImplDockFloatWin, DockTimerHdl ) );
-    maDockIdle.SetPriority( SchedulerPriority::MEDIUM );
+    maDockIdle.SetPriority( SchedulerPriority::HIGH_IDLE );
     maDockIdle.SetDebugName( "vcl::ImplDockFloatWin maDockIdle" );
 }
 
commit 70de16d1e30a1dee994d34e64085881f2a193d92
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Tue Sep 13 12:20:45 2016 +0200

    Don't wait in Yield with pending events
    
    This re-introduces some functionality of commit
      87199d3829257420429057336283c55be6ae7481
    
    Change-Id: Ie88c2945acb066e312bab7d0f5b2f3b525fa1c4c

diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index 66348fa..69684b3 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -23,6 +23,7 @@
 #include <vcl/dllapi.h>
 
 struct ImplSchedulerData;
+struct ImplSVData;
 
 enum class SchedulerPriority {
     HIGHEST      = 0,
@@ -45,6 +46,8 @@ private:
     static inline void UpdateMinPeriod( ImplSchedulerData *pSchedulerData,
                                         const sal_uInt64 nTime, sal_uInt64 &nMinPeriod );
 
+    static inline bool HasPendingEvents( const ImplSVData* pSVData, const sal_uInt64 nTime );
+
 protected:
     ImplSchedulerData*  mpSchedulerData;    /// Pointer to element in scheduler list
     const sal_Char     *mpDebugName;        /// Useful for debugging
@@ -88,6 +91,8 @@ public:
     static bool       ProcessTaskScheduling();
     /// Process all events until we are idle
     static void       ProcessAllPendingEvents();
+    /// Are there any pending tasks in the LO task queue?
+    static bool       HasPendingEvents();
 
     /// Control the deterministic mode.  In this mode, two subsequent runs of
     /// LibreOffice fire about the same amount idles.
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index a4a1fbd..0068a07 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -146,6 +146,19 @@ bool Scheduler::GetDeterministicMode()
     return g_bDeterministicMode;
 }
 
+inline bool Scheduler::HasPendingEvents( const ImplSVData* pSVData, const sal_uInt64 nTime )
+{
+   return ( pSVData->mbNeedsReschedule || ((pSVData->mnTimerPeriod != InfiniteTimeoutMs)
+       && (nTime >= pSVData->mnLastUpdate + pSVData->mnTimerPeriod)) );
+}
+
+bool Scheduler::HasPendingEvents()
+{
+    ImplSVData*  pSVData = ImplGetSVData();
+    sal_uInt64   nTime = tools::Time::GetSystemTicks();
+    return HasPendingEvents( pSVData, nTime );
+}
+
 inline void Scheduler::UpdateMinPeriod( ImplSchedulerData *pSchedulerData,
                                         const sal_uInt64 nTime, sal_uInt64 &nMinPeriod )
 {
@@ -158,8 +171,7 @@ bool Scheduler::ProcessTaskScheduling()
 {
     ImplSVData*        pSVData = ImplGetSVData();
     sal_uInt64         nTime = tools::Time::GetSystemTicks();
-    if (!pSVData->mbNeedsReschedule &&
-            (nTime < pSVData->mnLastUpdate + pSVData->mnTimerPeriod) )
+    if ( !HasPendingEvents( pSVData, nTime ) )
         return false;
     pSVData->mbNeedsReschedule = false;
 
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index df61726..2cc424b 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -477,6 +477,9 @@ inline bool ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
     SAL_INFO("vcl.schedule", "Enter ImplYield: " << (i_bWait ? "wait" : "no wait") <<
              ": " << (i_bAllEvents ? "all events" : "one event") << ": " << nReleased);
 
+    if ( i_bWait && Scheduler::HasPendingEvents() )
+        i_bWait = false;
+
     // TODO: there's a data race here on WNT only because ImplYield may be
     // called without SolarMutex; if we can get rid of LazyDelete (with VclPtr)
     // then the only remaining use of mnDispatchLevel is in OSX specific code
commit 4908a3e4fc47b151081b32fe5bb941b7c650e4fe
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Sun Jul 31 17:31:07 2016 +0200

    Just schedule tasks, if timeout has ellapsed
    
    As the native main loop wakes up on new events and not just by
    timer timeouts, make sure there is really an ellapsed event.
    
    Probably we should just schedule events via the system timeout.
    At least this will prevent expensive re-scheduling.
    
    Change-Id: I248c9b8acb7df026295d10f256871b9fc8d39c07

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 173c166..27c4cfc 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -314,13 +314,17 @@ struct ImplSVData
     Application*            mpApp = nullptr;                // pApp
     VclPtr<WorkWindow>      mpDefaultWin;                   // Default-Window
     bool                    mbDeInit = false;               // Is VCL deinitializing
+
     ImplSchedulerData*      mpFirstSchedulerData = nullptr; // list of all running tasks
     ImplSchedulerData*      mpFreeSchedulerData = nullptr;  // list of all deleted tasks for reuse
+    bool                    mbNeedsReschedule = false;      // was the list of tasks changed?
+    sal_uInt64              mnTimerPeriod = 0;              // current timer period / sleep time
+    sal_uInt64              mnLastUpdate = 0;               // last scheduler time
     SalTimer*               mpSalTimer = nullptr;           // interface to sal event loop/timers
+
     SalI18NImeStatus*       mpImeStatus = nullptr;          // interface to ime status window
     SalSystem*              mpSalSystem = nullptr;          // SalSystem interface
     ResMgr*                 mpResMgr = nullptr;             // SV-Resource-Manager
-    sal_uInt64              mnTimerPeriod = 0;              // current timer period
     ImplSVAppData           maAppData;                      // indepen data for class Application
     ImplSVGDIData           maGDIData;                      // indepen data for Output classes
     ImplSVWinData           maWinData;                      // indepen data for Windows classes
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 51711b1..a4a1fbd 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -129,6 +129,8 @@ void Scheduler::ImplStartTimer( sal_uInt64 nMS, bool bForce )
 void Scheduler::CallbackTaskScheduling()
 {
     // this function is for the saltimer callback
+    ImplSVData* pSVData = ImplGetSVData();
+    pSVData->mbNeedsReschedule = true;
     Scheduler::ProcessTaskScheduling();
 }
 
@@ -155,11 +157,15 @@ inline void Scheduler::UpdateMinPeriod( ImplSchedulerData *pSchedulerData,
 bool Scheduler::ProcessTaskScheduling()
 {
     ImplSVData*        pSVData = ImplGetSVData();
+    sal_uInt64         nTime = tools::Time::GetSystemTicks();
+    if (!pSVData->mbNeedsReschedule &&
+            (nTime < pSVData->mnLastUpdate + pSVData->mnTimerPeriod) )
+        return false;
+    pSVData->mbNeedsReschedule = false;
+
     ImplSchedulerData* pSchedulerData = pSVData->mpFirstSchedulerData;
     ImplSchedulerData* pPrevSchedulerData = nullptr;
     ImplSchedulerData *pMostUrgent = nullptr;
-
-    sal_uInt64         nTime = tools::Time::GetSystemTicks();
     sal_uInt64         nMinPeriod = InfiniteTimeoutMs;
 
     while ( pSchedulerData )
@@ -221,6 +227,7 @@ next_entry:
         pSVData->mpSalTimer->Stop();
 
     pSVData->mnTimerPeriod = nMinPeriod;
+    pSVData->mnLastUpdate = nTime;
 
     return pMostUrgent != nullptr;
 }
@@ -260,7 +267,10 @@ void Scheduler::Start()
         else
             pSVData->mpFirstSchedulerData = mpSchedulerData;
     }
-    mpSchedulerData->mnUpdateTime  = tools::Time::GetSystemTicks();
+
+    assert( mpSchedulerData->mpScheduler == this );
+    mpSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
+    pSVData->mbNeedsReschedule = true;
 }
 
 void Scheduler::Stop()
commit 72fba42d38c60c6aa70d7a121d0d6b70cade3935
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Mon Sep 12 17:03:29 2016 +0200

    Drop special idle handling
    
    Idles are just instant, mainly low-priority timers.
    So we'll just schedule by priority.
    
    This basically also reverts the following commit:
    
      commit 06d731428ef6cf93c7333e8228bfb6088853b52f
    
    Change-Id: I446eaea0077f45a5b7daa0aa06dcb80010ac0bd5

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index bcf019e..f439698 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -389,7 +389,7 @@ void DesktopLOKTest::testSearchCalc()
         {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))},
     }));
     comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     std::vector<OString> aSelections;
     sal_Int32 nIndex = 0;
@@ -423,7 +423,7 @@ void DesktopLOKTest::testSearchAllNotificationsCalc()
         {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))},
     }));
     comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // This was 1, make sure that we get no notifications about selection changes during search.
     CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult);
@@ -693,7 +693,7 @@ void DesktopLOKTest::testCommandResult()
     // the condition var.
     m_aCommandResultCondition.reset();
     pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", nullptr, true);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     m_aCommandResultCondition.wait(aTimeValue);
 
     CPPUNIT_ASSERT(m_aCommandResult.isEmpty());
@@ -703,7 +703,7 @@ void DesktopLOKTest::testCommandResult()
 
     m_aCommandResultCondition.reset();
     pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", nullptr, true);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     m_aCommandResultCondition.wait(aTimeValue);
 
     boost::property_tree::ptree aTree;
@@ -726,7 +726,7 @@ void DesktopLOKTest::testWriterComments()
     TimeValue aTimeValue = {2 , 0}; // 2 seconds max
     m_aCommandResultCondition.reset();
     pDocument->pClass->postUnoCommand(pDocument, ".uno:InsertAnnotation", nullptr, true);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     m_aCommandResultCondition.wait(aTimeValue);
     CPPUNIT_ASSERT(!m_aCommandResult.isEmpty());
     xToolkit->reschedule();
@@ -767,10 +767,10 @@ void DesktopLOKTest::testModifiedStatus()
     m_bModified = false;
     m_aStateChangedCondition.reset();
     pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max
     m_aStateChangedCondition.wait(aTimeValue);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // This was false, there was no callback about the modified status change.
     CPPUNIT_ASSERT(m_bModified);
@@ -781,9 +781,9 @@ void DesktopLOKTest::testModifiedStatus()
     utl::TempFile aTempFile;
     aTempFile.EnableKillingFile();
     CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "odt", "TakeOwnership"));
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     m_aStateChangedCondition.wait(aTimeValue);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // There was no callback about the modified status change.
     CPPUNIT_ASSERT(!m_bModified);
@@ -791,9 +791,9 @@ void DesktopLOKTest::testModifiedStatus()
     // Modify the document again
     m_aStateChangedCondition.reset();
     pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     m_aStateChangedCondition.wait(aTimeValue);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // There was no callback about the modified status change.
     CPPUNIT_ASSERT(m_bModified);
@@ -806,7 +806,7 @@ void DesktopLOKTest::testModifiedStatus()
     m_aStateChangedCondition.reset();
     pDocument->pClass->postUnoCommand(pDocument, ".uno:Save", nullptr, false);
     m_aStateChangedCondition.wait(aTimeValue);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // There was no callback about the modified status change.
     CPPUNIT_ASSERT(!m_bModified);
@@ -826,12 +826,12 @@ void DesktopLOKTest::testTrackChanges()
     pDocument->pClass->createView(pDocument);
     pDocument->pClass->initializeForRendering(pDocument, nullptr);
     pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // Enable trak changes and assert that both views get notified.
     m_nTrackChanges = 0;
     pDocument->pClass->postUnoCommand(pDocument, ".uno:TrackChanges", nullptr, false);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     // This was 1, only the active view was notified.
     CPPUNIT_ASSERT_EQUAL(2, m_nTrackChanges);
 
@@ -1063,7 +1063,7 @@ void DesktopLOKTest::testContextMenuCalc()
                                       LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
                                       aPointOnImage.X(), aPointOnImage.Y(),
                                       1, 4, 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     TimeValue aTimeValue = {2 , 0}; // 2 seconds max
     m_aContextMenuCondition.wait(aTimeValue);
@@ -1173,7 +1173,7 @@ void DesktopLOKTest::testContextMenuWriter()
                                       LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
                                       aRandomPoint.X(), aRandomPoint.Y(),
                                       1, 4, 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     TimeValue aTimeValue = {2 , 0}; // 2 seconds max
     m_aContextMenuCondition.wait(aTimeValue);
@@ -1229,7 +1229,7 @@ void DesktopLOKTest::testContextMenuImpress()
                                       LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
                                       aRandomPoint.X(), aRandomPoint.Y(),
                                       1, 4, 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     TimeValue aTimeValue = {2 , 0}; // 2 seconds max
     m_aContextMenuCondition.wait(aTimeValue);
@@ -1385,7 +1385,7 @@ void DesktopLOKTest::testNotificationCompression()
     handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // Should be dropped.
     handler->queue(LOK_CALLBACK_SET_PART, "1"); // Should be dropped.
 
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(13), notifs.size());
 
@@ -1441,7 +1441,7 @@ void DesktopLOKTest::testPartInInvalidation()
         handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10");
         handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10");
 
-        Scheduler::ProcessEventsToIdle();
+        Scheduler::ProcessAllPendingEvents();
 
         CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), notifs.size());
 
@@ -1456,7 +1456,7 @@ void DesktopLOKTest::testPartInInvalidation()
         handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10");
         handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "40, 10, 20, 10");
 
-        Scheduler::ProcessEventsToIdle();
+        Scheduler::ProcessAllPendingEvents();
 
         CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), notifs.size());
     }
@@ -1475,7 +1475,7 @@ void DesktopLOKTest::testPartInInvalidation()
         handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10, 0");
         handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10, 0");
 
-        Scheduler::ProcessEventsToIdle();
+        Scheduler::ProcessAllPendingEvents();
 
         CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), notifs.size());
     }
@@ -1493,7 +1493,7 @@ void DesktopLOKTest::testPartInInvalidation()
         handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10, 0");
         handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10, 1");
 
-        Scheduler::ProcessEventsToIdle();
+        Scheduler::ProcessAllPendingEvents();
 
         // This failed as RectangleAndPart::Create() always assumed no part in
         // payload, so this was merged -> it was 1.
@@ -1630,11 +1630,11 @@ void DesktopLOKTest::testPaintPartTile()
     pDocument->m_pDocumentClass->paintPartTile(pDocument, pPixels, 1, 256, 256, 0, 0, 256, 256);
 
     // Type again.
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     aView1.m_bTilesInvalidated = false;
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     // This failed: paintPartTile() (as a side-effect) ended the text edit of
     // the first view, so there were no invalidations.
     CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
@@ -1658,7 +1658,7 @@ void DesktopLOKTest::testWriterCommentInsertCursor()
     pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView2);
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     Rectangle aBodyCursor = aView2.m_aOwnCursor;
 
     // Now insert a comment and make sure that the comment's cursor is shown,
@@ -1667,11 +1667,11 @@ void DesktopLOKTest::testWriterCommentInsertCursor()
     const int nCtrlAltC = KEY_MOD1 + KEY_MOD2 + 512 + 'c' - 'a';
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'c', nCtrlAltC);
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 'c', nCtrlAltC);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     // Wait for SfxBindings to actually update the state, which updated the
     // cursor as well.
     osl::Thread::wait(std::chrono::seconds(1));
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     // This failed: the body cursor was shown right after inserting a comment.
     CPPUNIT_ASSERT(aView2.m_aOwnCursor.getX() > aBodyCursor.getX());
     // This failed, the first view's cursor also jumped when the second view
diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx
index 1027f0c..f50e329 100644
--- a/include/vcl/idle.hxx
+++ b/include/vcl/idle.hxx
@@ -31,7 +31,7 @@ protected:
 
     virtual void SetDeletionFlags() override;
 
-    virtual bool ReadyForSchedule( const sal_uInt64 nTime, const bool bIdle ) const override;
+    virtual bool ReadyForSchedule( const sal_uInt64 nTime ) const override;
     virtual void UpdateMinPeriod( const sal_uInt64 nTime, sal_uInt64 &nMinPeriod ) const override;
 
 public:
diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index 30da4f0..66348fa 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -57,7 +57,7 @@ protected:
 
     virtual void SetDeletionFlags();
 
-    virtual bool ReadyForSchedule( const sal_uInt64 nTime, const bool bIdle ) const = 0;
+    virtual bool ReadyForSchedule( const sal_uInt64 nTime ) const = 0;
     virtual void UpdateMinPeriod( const sal_uInt64 nTime, sal_uInt64 &nMinPeriod ) const = 0;
 
 public:
@@ -83,11 +83,11 @@ public:
     static void ImplDeInitScheduler();
 
     /// Process one pending Timer with highhest priority
-    static void CallbackTaskScheduling( bool bIdle );
+    static void       CallbackTaskScheduling();
     /// Process one pending task ahead of time with highest priority.
-    static bool       ProcessTaskScheduling( bool bIdle );
+    static bool       ProcessTaskScheduling();
     /// Process all events until we are idle
-    static void       ProcessEventsToIdle();
+    static void       ProcessAllPendingEvents();
 
     /// Control the deterministic mode.  In this mode, two subsequent runs of
     /// LibreOffice fire about the same amount idles.
diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index e4c922e..4f7e3d8 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -32,7 +32,7 @@ protected:
 
     virtual void SetDeletionFlags() override;
 
-    virtual bool ReadyForSchedule( const sal_uInt64 nTime, const bool bIdle ) const override;
+    virtual bool ReadyForSchedule( const sal_uInt64 nTime ) const override;
     virtual void UpdateMinPeriod( const sal_uInt64 nTime, sal_uInt64 &nMinPeriod ) const override;
 
 public:
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 83db147..12c1133 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -488,7 +488,7 @@ void ScTiledRenderingTest::testViewCursors()
     CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     SfxLokHelper::destroyView(SfxLokHelper::getView());
     CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated);
     mxComponent->dispose();
@@ -527,7 +527,7 @@ void ScTiledRenderingTest::testTextViewSelection()
     // Create a selection on two cells in the second view, that's a text selection in LOK terms.
     aView1.m_bTextViewSelectionInvalidated = false;
     lcl_dispatchCommand(mxComponent, ".uno:GoRightSel", {});
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     // Make sure the first view got its notification.
     CPPUNIT_ASSERT(aView1.m_bTextViewSelectionInvalidated);
 
@@ -550,7 +550,7 @@ void ScTiledRenderingTest::testDocumentSizeChanged()
         comphelper::makePropertyValue("ToPoint", OUString("$A$30")),
     };
     lcl_dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     // Assert that the size in the payload is not 0.
     CPPUNIT_ASSERT(m_aDocumentSize.getWidth() > 0);
     CPPUNIT_ASSERT(m_aDocumentSize.getHeight() > 0);
@@ -685,7 +685,7 @@ void ScTiledRenderingTest::testTextEditViews()
     // text edit a cell in view #1
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     CPPUNIT_ASSERT(lcl_hasEditView(*pViewData));
 
     // view #2
@@ -697,7 +697,7 @@ void ScTiledRenderingTest::testTextEditViews()
     // move cell cursor i view #2
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // check that text edit view in view #1 has not be killed
     CPPUNIT_ASSERT(lcl_hasEditView(*pViewData));
@@ -734,7 +734,7 @@ void ScTiledRenderingTest::testTextEditViewInvalidations()
     aView2.m_bInvalidateTiles = false;
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     CPPUNIT_ASSERT(lcl_hasEditView(*pViewData));
     CPPUNIT_ASSERT(aView2.m_bInvalidateTiles);
 
@@ -745,14 +745,14 @@ void ScTiledRenderingTest::testTextEditViewInvalidations()
         pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
         pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
     }
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // text edit a cell in view #1 inside the new tile and
     // check that view #2 receive a tile invalidate message
     aView2.m_bInvalidateTiles = false;
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     CPPUNIT_ASSERT(aView2.m_bInvalidateTiles);
 
     // view #3
@@ -766,7 +766,7 @@ void ScTiledRenderingTest::testTextEditViewInvalidations()
     aView3.m_bInvalidateTiles = false;
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     CPPUNIT_ASSERT(aView3.m_bInvalidateTiles);
 
     mxComponent->dispose();
@@ -833,11 +833,11 @@ void ScTiledRenderingTest::testGraphicInvalidate()
     pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, /*x=*/ 1,/*y=*/ 1,/*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
     pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEMOVE, /*x=*/ 1,/*y=*/ 10,/*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
     pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, /*x=*/ 1, /*y=*/ 10, /*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     CPPUNIT_ASSERT(!aView.m_bFullInvalidateTiles);
 
     // Check again
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     CPPUNIT_ASSERT(!aView.m_bFullInvalidateTiles);
 
     mxComponent->dispose();
@@ -856,7 +856,7 @@ void ScTiledRenderingTest::testAutoSum()
 
     uno::Sequence<beans::PropertyValue> aArgs;
     comphelper::dispatchCommand(".uno:AutoSum", aArgs);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     CPPUNIT_ASSERT(aView.m_sCellFormula.startsWith("=SUM("));
 
     mxComponent->dispose();
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
index b926c0d..aa9b02b 100644
--- a/sd/qa/unit/misc-tests.cxx
+++ b/sd/qa/unit/misc-tests.cxx
@@ -93,7 +93,7 @@ sd::DrawDocShellRef SdMiscTest::Load(const OUString& rURL, sal_Int32 nFormat)
     for (int i = 0; i < 1000; i++)
     {
         // Process all Tasks - slide sorter is created here
-        while (Scheduler::ProcessTaskScheduling(true));
+        while (Scheduler::ProcessTaskScheduling());
         if ((pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase())) != nullptr)
             break;
         osl::Thread::wait(std::chrono::milliseconds(100));
@@ -137,7 +137,7 @@ void SdMiscTest::testTdf96708()
 
     // Now wait for timers to trigger creation of auto-layout
     osl::Thread::wait(std::chrono::milliseconds(100));
-    Scheduler::ProcessTaskScheduling(true);
+    Scheduler::ProcessTaskScheduling();
 
     rSSController.GetClipboard().DoPaste();
     const sal_uInt16 nMasterPageCnt2 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::Standard);
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index c156615..0df9ba8 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -457,7 +457,7 @@ void SdTiledRenderingTest::testUndoShells()
         {"AttributePageSize.Height", uno::makeAny(static_cast<sal_Int32>(10000))},
     }));
     comphelper::dispatchCommand(".uno:AttributePageSize", aPropertyValues);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // Assert that view shell ID tracking works for SdUndoAction subclasses.
     SdDrawDocument* pDocument = pXImpressDocument->GetDoc();
@@ -734,7 +734,7 @@ void SdTiledRenderingTest::testInsertTable()
     ));
 
     comphelper::dispatchCommand(".uno:InsertTable", aArgs);
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // get the table
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
@@ -982,7 +982,7 @@ void SdTiledRenderingTest::testViewCursors()
     SdrObject* pObject = pActualPage->GetObj(0);
     SdrView* pView = pViewShell->GetView();
     pView->MarkObj(pObject, pView->GetSdrPageView());
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
 
     // First view notices that there was a selection change in the other view.
     CPPUNIT_ASSERT(aView1.m_bGraphicViewSelectionInvalidated);
@@ -1013,7 +1013,7 @@ void SdTiledRenderingTest::testViewCursorParts()
     SdrObject* pObject = pActualPage->GetObj(0);
     SdrView* pView = pViewShell->GetView();
     pView->MarkObj(pObject, pView->GetSdrPageView());
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     // First view notices that there was a selection change in the other view.
     CPPUNIT_ASSERT(aView1.m_bGraphicViewSelectionInvalidated);
     pView->UnmarkAllObj(pView->GetSdrPageView());
@@ -1025,7 +1025,7 @@ void SdTiledRenderingTest::testViewCursorParts()
     pActualPage = pViewShell->GetActualPage();
     pObject = pActualPage->GetObj(0);
     pView->MarkObj(pObject, pView->GetSdrPageView());
-    Scheduler::ProcessEventsToIdle();
+    Scheduler::ProcessAllPendingEvents();
     // First view ignores view selection, as it would be for part 1, and it's in part 0.
     // This failed when the "part" was always 0 in the callback.
     CPPUNIT_ASSERT(!aView1.m_bGraphicViewSelectionInvalidated);
@@ -1052,14 +1052,14 @@ void SdTiledRenderingTest::testCursorViews()
     pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB);
     pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list