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
gone.
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@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus