[Lazarus] A bitmap strange issue
Giuliano Colla
giuliano.colla at fastwebnet.it
Sun Apr 22 12:38:26 CEST 2018
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;
just copies the pointer. Timage.Picture.GetBitmap and
TImage.Picture.SetBitmap do not follow the same logic.
All of this is maybe somewhat Delphi compatible. Actually Delphi (Rad
Studio 10.1) doesn't generate a SIGSEV with the same code, but rather
just an "Illegal Pointer Operation" warning. However IMO it still
remains quite inconsistent.
Giuliano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180422/b1c265e3/attachment.html>
More information about the Lazarus
mailing list