[Libreoffice-commits] Adapt SwSrcEditWindow's SyntaxTimerHdl to being used in an Idle now
Stephan Bergmann
sbergman at redhat.com
Tue May 5 02:46:18 PDT 2015
I assume deleting the SetTimeout calls without replacement is fine, as
the idle handler will automatically keep being called again?
But then, is it OK that it only ever gets Stop()'ed in
SwSrcEditWindow::dispose, or should it also stop itself when there's no
more work to do?
And is it necessary to do that
if (... !pIdle->IsActive()) pIdle->Start();
thing from within the handler?
On 05/05/2015 10:22 AM, Stephan Bergmann wrote:
> commit c0e209bf5f418f1564d16e234251783a0857a9d4
> Author: Stephan Bergmann <sbergman at redhat.com>
> Date: Tue May 5 10:16:43 2015 +0200
>
> Adapt SwSrcEditWindow's SyntaxTimerHdl to being used in an Idle now
>
> ...not a Timer, since d843f3de731667a298a83fc66637c7f983f3b24d "changed timers
> to idle"
>
> Change-Id: If8c6a52d6fb7b1e392e8f31bc8f0db22b2f049e1
>
> diff --git a/sw/source/uibase/docvw/srcedtw.cxx b/sw/source/uibase/docvw/srcedtw.cxx
> index cd66ace..02e1e66 100644
> --- a/sw/source/uibase/docvw/srcedtw.cxx
> +++ b/sw/source/uibase/docvw/srcedtw.cxx
> @@ -56,7 +56,6 @@ struct SwTextPortion
>
> #define MAX_SYNTAX_HIGHLIGHT 20
> #define MAX_HIGHLIGHTTIME 200
> -#define SYNTAX_HIGHLIGHT_TIMEOUT 200
>
> typedef std::deque<SwTextPortion> SwTextPortions;
>
> @@ -579,7 +578,7 @@ IMPL_LINK(SwSrcEditWindow, ScrollHdl, ScrollBar*, pScroll)
> return 0;
> }
>
> -IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer )
> +IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Idle *, pIdle )
> {
> tools::Time aSyntaxCheckStart( tools::Time::SYSTEM );
> SAL_WARN_IF(pTextView == 0, "sw", "No View yet, but syntax highlighting?!");
> @@ -605,7 +604,6 @@ IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer )
> break;
> if((tools::Time( tools::Time::SYSTEM ).GetTime() - aSyntaxCheckStart.GetTime()) > MAX_HIGHLIGHTTIME )
> {
> - pTimer->SetTimeout( 2 * SYNTAX_HIGHLIGHT_TIMEOUT );
> break;
> }
> }
> @@ -620,13 +618,12 @@ IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer )
> nCount ++;
> if(tools::Time( tools::Time::SYSTEM ).GetTime() - aSyntaxCheckStart.GetTime() > MAX_HIGHLIGHTTIME)
> {
> - pTimer->SetTimeout( 2 * SYNTAX_HIGHLIGHT_TIMEOUT );
> break;
> }
> }
>
> - if(!aSyntaxLineTable.empty() && !pTimer->IsActive())
> - pTimer->Start();
> + if(!aSyntaxLineTable.empty() && !pIdle->IsActive())
> + pIdle->Start();
> // SyntaxTimerHdl is called when text changed
> // => good opportunity to determine text width!
> long nPrevTextWidth = nCurTextWidth;
> diff --git a/sw/source/uibase/inc/srcedtw.hxx b/sw/source/uibase/inc/srcedtw.hxx
> index 823e3cd..55e53f4 100644
> --- a/sw/source/uibase/inc/srcedtw.hxx
> +++ b/sw/source/uibase/inc/srcedtw.hxx
> @@ -95,7 +95,7 @@ private:
> using OutputDevice::SetFont;
> void SetFont();
>
> - DECL_LINK( SyntaxTimerHdl, Timer * );
> + DECL_LINK( SyntaxTimerHdl, Idle * );
> DECL_LINK( TimeoutHdl, Timer * );
>
> using Window::Notify;
More information about the LibreOffice
mailing list