|
Do we need to delete TTFText manually after call DrawArea.text |
| Posted by Jeremy Peng on Nov-17-2025 10:52 |
|
Dear chartdirect RD,
we are using chartdirector 7.0 C++ lib, and we call the "DrawArea.text" in our code in two way, one don't get the return value, the other doesn't, e.g.
1. drawArea->text(...)
2. Auto *ttft = drawArea->text(...)
But in our sonarqube check, it report a potential memory leak for these code,
please clarify whether these function call also need to manually delete the text object,
or DrawArea/chartdirector can handle this case automatically, we can just close the sonar issue as false alarm.
THanks,
Jeremy |
Re: Do we need to delete TTFText manually after call DrawArea.text |
| Posted by Peter Kwan on Nov-17-2025 21:38 |
|
Hi Jeremy,
I checked the ChartDirector documentation and found that there is a mistake. The TTFText object needs to be deleted but it is not mentioned in the documentation.
However, in our sample code, we do "delete" the TTFText object. An example is at:
https://www.advsofteng.com/doc/cdcpp.htm#tracklegend.htm
The TTFText is created near the end of the code. It uses text->destroy(); to "delete" the object.
There are 4 overloaded versions of DrawArea::text. Two of them do not return anything, so there is no need to delete anything. The other two return TTFText *, and it needs to be "deleted" by calling the "TTFText::destroy" method.
Best Regards
Peter Kwan |
Re: Do we need to delete TTFText manually after call DrawArea.text |
| Posted by Jeremy Peng on Nov-18-2025 08:45 |
|
hi Peter,
Thanks for your replay, I am clear now.
Please also check whether need to improve the document in future,
just in case, others class/function also has similar issue.
Thanks,
Jeremy |
|