[Lazarus] GTK2/X Appcrash when TPen.Pattern has invalid value
Marc Weustink
marc at dommelstein.nl
Sun Jan 7 11:39:11 CET 2018
On January 6, 2018 8:14:30 PM GMT+01:00, Alexander Hofmann via Lazarus <lazarus at lists.lazarus-ide.org> wrote:
>Dear all,
>
>I spend some time debugging a programming error (read:
>misinterpretation
>of available documentation) and though I should share my findings...
>
>I wanted to have a TChart series drawn with a dashed line, the
>pen-style
>"psDashed" had two short dashes for my eyes, so I used "psPattern" and
>set the Pen-Pattern as such:
>
>const
> Pattern:array [0..7] of longint=(1, 1, 1, 1, 0, 0, 0, 0)
>
>This is wrong of course; however reading some google I thought that
>each
>array element in the TPenPattern array describes one pixel. The problem
>now was, that Qt produces quite reasonable results: a 4-pixel dashed
>line. Also GTK2 did the job - if the line was drawn _outside_ any
>Paint-Message.
>
>In that case (e.g. when actually setting this as a Pen-Pattern for a
>Chart series), the X-Function 58 (SetDashes) produced the Errorcode 2
>(Out of range) and the Program ended directly at the 1st Paint-Event -
>leaving Lazarus and GDB in the wild with no backtrace or alike.
>
>Of course it works now with the Pattern
>
>const
> Pattern:array [0..1] of longint=(4, 4)
>
>But: I think that, if this is the correct way to do it, and the value
>"0" for any portion of the pattern is indeed not allowed (as stated in
>the X-Documentation e.g. here:
>https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#requests:SetDashes),
>shouldn't TPen.SetPattern raise an exception when an invalid pattern is
>given?
Don't think so. The gtk implementation should have checked this and probably skip the 0
>I don't know about other OSes / Widgestsets, if there are the same
>"rules".
Imo the QT implementation should be adapted to behave the same.
Wat does Delphi in this case?
>I could try to file a bugreport / try to provide a patch; but maybe
>it's
>enough to cite the X-Docs somewhere in the Lazarus-Documentation? What
>do you think?
We shouldn't "copy"the x behaviour, but behave the same as Delphi.
Marc
More information about the Lazarus
mailing list