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?
I don't know about other OSes / Widgestsets, if there are the same "rules".
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?
Regards,
Alex
