[Lazarus] Exception with threads

faber faber.cpu at gmail.com
Mon Aug 2 14:50:29 CEST 2010


I have a fix for turbopower_ipro that will also fix the totally broken
scrollbar behavior of lhelp on GTk2 and probably also other widgetsets.

attached is the diff file, it fixes just one line of code in IpHtml.pas.

here is some part of the code from TIpHtmlScrollBar.ScrollMessage() as
it looks now after the fix, I have inserted as a comment the line that
was there previously. The fact that it worked on windows was a pure
coincidence, on windows there will never be a SB_THUMBPOSITION message,
the code in question will never be executed. On windows there will only
be SB_THUMBTRACK while on GTK2 there will be both messages.

Doing these odd things with FIncrement during a message that is supposed
to give me the *absolute* position of the scrollbar results in the
strange behavior of crazy jumping scroll position. This line might have
been some cut&paste accident, the wrong indedation of this line might be
evidence for this.

The correct way of handling the message must be SetPosition(Pos). The
attached patch will correct this and after recompiling the lhelp example
the chm-viwer lhelp will work correctly on linux GTK2.

here is the code snippet discussed above:

  with Msg do
    case ScrollCode of
    SB_LINEUP:
      SetPosition(FPosition - FIncrement);
    SB_LINEDOWN:
      SetPosition(FPosition + FIncrement);
    SB_PAGEUP:
      SetPosition(FPosition - ControlSize(True, False));
    SB_PAGEDOWN:
      SetPosition(FPosition + ControlSize(True, False));
    SB_THUMBPOSITION:
      if FCalcRange > 32767 then
        SetPosition(GetRealScrollPosition)
      else
        //  this is plain wrong:
        //  SetPosition( FPosition + (Pos - FPosition) * FIncrement );
        SetPosition(Pos);
    SB_THUMBTRACK:
      if Tracking then
        if FCalcRange > 32767 then
          SetPosition(GetRealScrollPosition)
        else
          SetPosition(Pos);
    SB_TOP:
      SetPosition(0);
    SB_BOTTOM:
      SetPosition(FCalcRange);
    SB_ENDSCROLL:
      ;
    end;

and attached you find the patch for IpHtml.pas. Apply it against
currrent svn version from within the trunk/ directory, then recompile
lhelp and enjoy flawlessly working chm help under gtk2.

Bernd
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ippro-fix-broken-scrollbar-behavior.diff
Type: text/x-diff
Size: 582 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100801/c9692b67/attachment-0002.diff>


More information about the Lazarus mailing list