On Wed, 25 Oct 2017, Ondrej Pokorny via Lazarus wrote:

On 24.10.2017 23:18, Michael Van Canneyt via Lazarus wrote:
On Tue, 24 Oct 2017, Giuliano Colla wrote:

Il 24/10/2017 14:10, Michael Van Canneyt via Lazarus ha scritto:
A valid method can never be stored in a pointer, since the former is actually 2 pointers (method/data) and the latter is just 1 pointer.

That the assignment is valid is Delphi compatible: only the procedure
address is copied.

I can confirm it as an fpc bug.

No, I'm sorry to say that IMO you did not. I looked at your code.

It simply works by accident in Delphi, because you are calling a method of the same object as the caller.

Yes, the code is wrong. But the reason is that myMethod is assigned in FormCreate. The later "@myMethod := pMethod;" assignment overwrites only half of the myMethod:TProc variable and so correct Self stays in the second half of myMethod.

That is what I wanted to indicate :)

Michael.
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to