[Lazarus] A bitmap strange issue
Michael Van Canneyt
michael at freepascal.org
Sun Apr 22 13:22:17 CEST 2018
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.
> 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.
More information about the Lazarus