<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 22.04.2018 12:38, Giuliano Colla via
Lazarus wrote:<br>
</div>
<blockquote type="cite"
cite="mid:31703db8-f433-dcb4-be73-6346f4cb1c63@fastwebnet.it">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<p>Il 21/04/2018 18:07, Vojtěch Čihák via Lazarus ha scritto:<br>
</p>
<blockquote type="cite"
cite="mid:20180421180724.027DDBC2@atlas.cz">
<p style="padding:0 0 0 0; margin:0 0 0 0;">@ <span
style="font-size: 10pt;">MyBitmap := Image1.Picture.Bitmap;</span></p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">This line only
copies pointer, but I<span style="font-size: 10pt;">mage1.Picture.Bitmap
belongs to Image1 and it should care itself.</span></p>
</blockquote>
<br>
That's what I had guessed, but this means that there's a patent
inconsistency, as shown in the Button2Click part of my test:<br>
<pre><blockquote type="cite"> Image1.Picture.Bitmap := MyBitmap;
FreeAndNil(MyBitmap);
</blockquote></pre>
doesn't generate any error. If I don't free MyBitmap I see a
memory leakage in heaptrc.<br>
<br>
IOW<br>
<pre>Image1.Picture.Bitmap := MyBitmap;</pre>
performs an implicit assign, creating a new Bitmap Object for
Image1.<br>
<br>
The apparently symmetrical<br>
<pre>MyBitmap := Image1.Picture.Bitmap;
</pre>
just copies the pointer. Timage.Picture.GetBitmap and
TImage.Picture.SetBitmap do not follow the same logic.<br>
</blockquote>
<br>
Do you really mean that <br>
Image1.Picture.Bitmap.SomeProperty := SomeValue;<br>
should apply SomeProperty := SomeValue on a copied object of Bitmap
and produce a memory leak?<br>
<br>
And the same, that<br>
Image1.Picture.Bitmap := Image2.Picture.Bitmap;<br>
should produce a memory leak because of the temporary bitmap object?<br>
<br>
...and taking it into detail because Picture is a property of TImage
as well:<br>
Image1.Picture.Bitmap := Image2.Picture.Bitmap;<br>
would actually produce 3 memory leaks: 2x TPicture and 1x TBitmap.<br>
<br>
Ondrej<br>
</body>
</html>