Page 1 of 1

[TSimpleGraph] BUG: random characters in text

PostPosted: March 20th, 2013, 10:41 am
by zizzo81
I just compiled the demo application attacched to the download, run it and add a Link line, then go to properties and put in "aaa" as text, as you click Apply or OK the text will appear but will be "aaa" + some weird chinese/japanese characters. Sometime this does not happen, but going in properties again and changing text will do.

Trying to track down the problem I got to the line inside the TGraphLink.DrawText procedure:

Code: Select all
    ExtTextOut(DC, TextCenter.X, TextCenter.Y, TextFlags, nil,
      PChar(TextToShow), Length(TextToShow), nil);


I can't understand what's exactly going on there, code seems to be fine, but does weird things.
Maybe the implicit cast to PChar leaves some bad character into memory without nulling the next character.

This applies to:
TSimpleGraph 2.80
Delphi XE2

Christian

Re: [TSimpleGraph] BUG: random characters in text

PostPosted: March 20th, 2013, 6:01 pm
by Kambiz
Dear Christian,

Thank you for reporting this bug.

Currently I do not have XE2 but as soon as I get access to it, I'll try to fix the issue.

Re: [TSimpleGraph] BUG: random characters in text

PostPosted: March 23rd, 2013, 8:16 pm
by mathgod
This looks like a unicode anomaly. Find where the string is output to the link label and apply the ansistring function. Re-compile. Test again.

Re: [TSimpleGraph] BUG: random characters in text

PostPosted: April 27th, 2013, 2:04 pm
by Kambiz
I fixed the bug and it was because of a missing null character terminator that causing 4 extra bytes to the output.

You may want to download the update from the SimpleGraph's page.