summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/IDocumentTimerAccess.hxx9
-rw-r--r--sw/source/core/doc/DocumentTimerManager.cxx45
-rw-r--r--sw/source/core/inc/DocumentTimerManager.hxx8
3 files changed, 36 insertions, 26 deletions
diff --git a/sw/inc/IDocumentTimerAccess.hxx b/sw/inc/IDocumentTimerAccess.hxx
index 1ed8679c00ac..f3e2738485af 100644
--- a/sw/inc/IDocumentTimerAccess.hxx
+++ b/sw/inc/IDocumentTimerAccess.hxx
@@ -21,7 +21,7 @@
#define INCLUDED_SW_INC_IDOCUMENTTIMERACCESS_HXX
/**
- * Handle the background job of the Writer document.
+ * Handle the background jobs of a Writer document.
*
* Initially it's disabled and unblocked.
*
@@ -34,7 +34,9 @@ class IDocumentTimerAccess
{
public:
/**
- * Start the idle job depending on the block count.
+ * Start the idle task.
+ *
+ * Depends on the block count and various document states.
*/
virtual void StartIdling() = 0;
@@ -47,13 +49,14 @@ public:
* Increment block count.
*
* Prevents further background idle processing.
+ * This doesn't guarantee the Idle task is not currently running!
*/
virtual void BlockIdling() = 0;
/**
* Decrement block count.
*
- * May start the idle job.
+ * May re-start the idle task, if active.
*/
virtual void UnblockIdling() = 0;
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx
index 35f2eb94dcbd..7bd2e505a3a4 100644
--- a/sw/source/core/doc/DocumentTimerManager.cxx
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -33,50 +33,56 @@
#include <docsh.hxx>
#include <docfld.hxx>
#include <fldbas.hxx>
+#include <vcl/scheduler.hxx>
namespace sw
{
DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ),
- mbStartIdleTimer( false ),
- mIdleBlockCount( 0 ),
- maDocIdle( i_rSwdoc )
+ m_nIdleBlockCount( 0 ),
+ m_bStartOnUnblock( false ),
+ m_aDocIdle( i_rSwdoc )
{
- maDocIdle.SetPriority( TaskPriority::LOWEST );
- maDocIdle.SetInvokeHandler( LINK( this, DocumentTimerManager, DoIdleJobs) );
- maDocIdle.SetDebugName( "sw::DocumentTimerManager maDocIdle" );
+ m_aDocIdle.SetPriority(TaskPriority::LOWEST);
+ m_aDocIdle.SetInvokeHandler(LINK( this, DocumentTimerManager, DoIdleJobs));
+ m_aDocIdle.SetDebugName("sw::DocumentTimerManager m_aDocIdle");
}
void DocumentTimerManager::StartIdling()
{
- if( !mIdleBlockCount && !maDocIdle.IsActive() )
+ m_bStartOnUnblock = true;
+ if (0 == m_nIdleBlockCount)
{
- mbStartIdleTimer = false;
- maDocIdle.Start();
+ if (!m_aDocIdle.IsActive())
+ m_aDocIdle.Start();
+ else
+ Scheduler::Wakeup();
}
- else
- mbStartIdleTimer = true;
}
void DocumentTimerManager::StopIdling()
{
- mbStartIdleTimer = false;
- maDocIdle.Stop();
+ m_bStartOnUnblock = false;
+ m_aDocIdle.Stop();
}
void DocumentTimerManager::BlockIdling()
{
- maDocIdle.Stop();
- ++mIdleBlockCount;
+ assert(SAL_MAX_UINT32 != m_nIdleBlockCount);
+ ++m_nIdleBlockCount;
}
void DocumentTimerManager::UnblockIdling()
{
- --mIdleBlockCount;
- if( !mIdleBlockCount && mbStartIdleTimer && !maDocIdle.IsActive() )
+ assert(0 != m_nIdleBlockCount);
+ --m_nIdleBlockCount;
+
+ if ((0 == m_nIdleBlockCount) && m_bStartOnUnblock)
{
- mbStartIdleTimer = false;
- maDocIdle.Start();
+ if (!m_aDocIdle.IsActive())
+ m_aDocIdle.Start();
+ else
+ Scheduler::Wakeup();
}
}
@@ -131,6 +137,7 @@ IMPL_LINK_NOARG( DocumentTimerManager, DoIdleJobs, Timer*, void )
pModLogFile = new ::rtl::Logfile( "First DoIdleJobs" );
#endif
BlockIdling();
+ StopIdling();
IdleJob eJob = GetNextIdleJob();
diff --git a/sw/source/core/inc/DocumentTimerManager.hxx b/sw/source/core/inc/DocumentTimerManager.hxx
index 214c0f626a75..2caaf608c40d 100644
--- a/sw/source/core/inc/DocumentTimerManager.hxx
+++ b/sw/source/core/inc/DocumentTimerManager.hxx
@@ -66,14 +66,14 @@ private:
SwDoc& m_rDoc;
- bool mbStartIdleTimer; //< idle timer mode start/stop
- sal_Int32 mIdleBlockCount;
- SwDocIdle maDocIdle;
+ sal_uInt32 m_nIdleBlockCount; ///< Don't run the Idle, if > 0
+ bool m_bStartOnUnblock; ///< true, if the last unblock should start the timer
+ SwDocIdle m_aDocIdle;
};
inline bool DocumentTimerManager::IsDocIdle() const
{
- return( GetNextIdleJob() != IdleJob::Busy );
+ return ((0 == m_nIdleBlockCount) && (GetNextIdleJob() != IdleJob::Busy));
}
}