tdf#116370 cleanup Writer idle job handing

This prevents the start of the idle job, while processing itself,
so the fixed WinSalInstance::AnyInput of commit 3bf6c97029
("tdf#112975 WIN correctly handle VclInputFlags::OTHER") won't
report the timer events of the re-started idle job to process.

Fixes the early abort of the background job, which resulted in
the busy loop of the reported bug and this strange printing
behaviour.

P.S. I'm not sure, why this was just broken on Windows.

Change-Id: I6503dcd925c9a0ed843e794a31eea32a4a4b2889
Reviewed-on: https://gerrit.libreoffice.org/59279
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
This commit is contained in:
Jan-Marek Glogowski 2018-08-17 23:10:00 +02:00
parent 35a2547503
commit 401cba4c20
5 changed files with 37 additions and 35 deletions

View file

@ -20,41 +20,43 @@
#ifndef INCLUDED_SW_INC_IDOCUMENTTIMERACCESS_HXX
#define INCLUDED_SW_INC_IDOCUMENTTIMERACCESS_HXX
/** Manipulate background jobs of the document. It starts with a mode of
'started' and a block count of 0.
/**
* Handle the background job of the Writer document.
*
* Initially it's disabled and unblocked.
*
* Jobs include:
* * grammar checking
* * field updating
* * document layouting
*/
class IDocumentTimerAccess
{
public:
/**
Set mode to 'start'.
*/
* Start the idle job depending on the block count.
*/
virtual void StartIdling() = 0;
/**
Set mode to 'stopped'.
*/
* Stop idle processing.
*/
virtual void StopIdling() = 0;
/**
Increment block count.
*/
* Increment block count.
*
* Prevents further background idle processing.
*/
virtual void BlockIdling() = 0;
/**
Decrement block count.
*/
* Decrement block count.
*
* May start the idle job.
*/
virtual void UnblockIdling() = 0;
/**
Do these jobs asynchronously: do grammar checking,
do layout, and update fields.
They will be delayed until mode is start AND block count == 0.
The implementation might delay them further, for example
it might wait until the application is idle.
*/
virtual void StartBackgroundJobs() = 0;
/**
* Is the document ready to be processed?
*/

View file

@ -49,9 +49,13 @@ DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc
void DocumentTimerManager::StartIdling()
{
mbStartIdleTimer = true;
if( !mIdleBlockCount )
if( !mIdleBlockCount && !maDocIdle.IsActive() )
{
mbStartIdleTimer = false;
maDocIdle.Start();
}
else
mbStartIdleTimer = true;
}
void DocumentTimerManager::StopIdling()
@ -70,14 +74,10 @@ void DocumentTimerManager::UnblockIdling()
{
--mIdleBlockCount;
if( !mIdleBlockCount && mbStartIdleTimer && !maDocIdle.IsActive() )
{
mbStartIdleTimer = false;
maDocIdle.Start();
}
void DocumentTimerManager::StartBackgroundJobs()
{
// Trigger DoIdleJobs(), asynchronously.
if (!maDocIdle.IsActive()) //fdo#73165 if the timer is already running don't restart from 0
maDocIdle.Start();
}
}
DocumentTimerManager::IdleJob DocumentTimerManager::GetNextIdleJob() const
@ -123,13 +123,14 @@ DocumentTimerManager::IdleJob DocumentTimerManager::GetNextIdleJob() const
return IdleJob::None;
}
IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, void )
IMPL_LINK_NOARG( DocumentTimerManager, DoIdleJobs, Timer*, void )
{
#ifdef TIMELOG
static ::rtl::Logfile* pModLogFile = 0;
if( !pModLogFile )
pModLogFile = new ::rtl::Logfile( "First DoIdleJobs" );
#endif
BlockIdling();
IdleJob eJob = GetNextIdleJob();
@ -183,7 +184,8 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, void )
}
if ( IdleJob::None != eJob )
pIdle->Start();
StartIdling();
UnblockIdling();
#ifdef TIMELOG
if( pModLogFile && 1 != (long)pModLogFile )

View file

@ -54,8 +54,6 @@ public:
void UnblockIdling() override;
void StartBackgroundJobs() override;
bool IsDocIdle() const override;
private:

View file

@ -170,7 +170,7 @@ public:
if (b)
{
pDocument->getIDocumentTimerAccess().StartBackgroundJobs();
pDocument->getIDocumentTimerAccess().StartIdling();
}
}

View file

@ -245,7 +245,7 @@ public:
// May be NULL if called from SfxBaseModel::dispose
// (this happens in the build test 'rtfexport').
if (pCurrShell != nullptr)
pCurrShell->GetDoc()->getIDocumentTimerAccess().StartBackgroundJobs();
pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling();
}
bool IsIdleFormat() const { return mbIdleFormat; }
void ResetIdleFormat() { mbIdleFormat = false; }
@ -261,7 +261,7 @@ public:
// May be NULL if called from SfxBaseModel::dispose
// (this happens in the build test 'rtfexport').
if (pCurrShell != nullptr)
pCurrShell->GetDoc()->getIDocumentTimerAccess().StartBackgroundJobs();
pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling();
}
}