[Lazarus] TTreeView, string and SIGSEGV
xrfang at gmail.com
Mon Aug 26 10:45:35 CEST 2013
Ok, that's reasonable, however:
1) If I use Move() is there a "manual" way to increate the string ref count?
2) why the error is gone if I change this line:
prev := tv.Items.InsertObjectBehind(prev, p^.title, p);
prev := tv.Items.InsertObjectBehind(prev, 'Node #' + IntToStr(i), p);
3) Why this error does not happen on node #0 and #3, but only node #1 and
4) Why it behaves different on Windows and Linux?
2013/8/24 Martin <lazarus at mfriebe.de>
> On 23/08/2013 16:13, Xiangrong Fang wrote:
>> Hi All,
>> I encountered a strange SIGSEGV with the attached program. To reproduce
>> the problem:
>> 1) compile and run it.
>> 2) select "Node #2"
>> 3) click "Test" button, it will insert a node before the selected Node
>> 4) close the program
>> There will be a SIGSEGV at the end of OnDestroy method.
>> This problem is reproducible under Linux amd64 and Wine and Win7 (32bit).
>> A strange thing is that on Linux or Wine, this error only occur on Node #1
>> and Node #2, but on Windows, it only occur on Node #2 and Node #3.
>> Also, if you swap either of the 2 commented statements, this error is
>> I suspect this is caused by the AnsiString manager. Could anyone explain
>> why, or is this a bug?
> Only had a quick look, please veryfy....
> Move(tv.Selected.Data^, p^, SizeOf(TNode));
> tv.Items.InsertObject(tv.**Selected, 'New Node', p);
> Move makes a copy of the node, including a copy of the ansistring (that is
> the pointer-part) in the node.
> so now you have 2 strings, referring the same string data, but you never
> increased the ref count.
> Lazarus mailing list
> Lazarus at lists.lazarus.**freepascal.org<Lazarus at lists.lazarus.freepascal.org>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Lazarus