[Libreoffice-commits] Adapt SwSrcEditWindow's SyntaxTimerHdl to being used in an Idle now

Tobias Madl tobias.madl.dev at gmail.com
Wed May 6 01:03:49 PDT 2015


So yeah SetTimeout should be deletet, but it should be replaced with
SetPriority (and of course set with an appropriate Priority), because
otherwise it gets the default priority: HIGH.

The taks should be stopped if there is absolutely no more work to do. If
stop is called it gets completely removed of the tasklist. So if you think
that it has no more work todo you can stop it by yourself.

But i think i get your point, because i see that i missed to ask if the
task is active (i only check if it should be delete). I wil change this and
then you could set the task as inactive if you think that for now it has no
more work to do and if it comes to the position:


  if (... !pIdle->IsActive()) pIdle->Start();

it should be reactivatet.

On Tue, May 5, 2015 at 11:46 AM, Stephan Bergmann <sbergman at redhat.com>
wrote:

> 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;
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20150506/4d7c058f/attachment.html>


More information about the LibreOffice mailing list