On Sun, 22 Apr 2018, Giuliano Colla via Lazarus wrote:
Il 21/04/2018 18:07, Vojtěch Čihák via Lazarus ha scritto:
@ MyBitmap := Image1.Picture.Bitmap;
This line only copies pointer, but Image1.Picture.Bitmap belongs to Image1
and it should care itself.
That's what I had guessed, but this means that there's a patent
inconsistency, as shown in the Button2Click part of my test:
Image1.Picture.Bitmap := MyBitmap; FreeAndNil(MyBitmap);
doesn't generate any error. If I don't free MyBitmap I see a memory leakage
in heaptrc.
IOW
Image1.Picture.Bitmap := MyBitmap;
performs an implicit assign, creating a new Bitmap Object for Image1.
The apparently symmetrical
MyBitmap := Image1.Picture.Bitmap;
This is how all properties that are TPersistent descendents work, so this
behaviour should not come as a surprise.
Michael.
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus