Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-09

TLazIntfImage.Assign ?

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

LacaK

Hi,

Please look at implementation :

procedure TLazIntfImage.Assign(Source: TPersistent);
var
   Src: TLazIntfImage;
   Desc: TRawImageDescription;
begin
   if Source is TLazIntfImage then begin
       Src:=TLazIntfImage(Source);
       Desc:=Src.DataDescription;
       Desc.Width:=0; // avoid side effects
       Desc.Height:=0; // avoid side effects
       DataDescription:=Src.DataDescription;
   end;
   inherited Assign(Source);
end;

Why we set Desc.Width and Height to 0 and later we do not use "Desc" , but "Src.DataDescription" ?

-Laco.

Reply by email

Juha Manninen
to LacaK
LacaK wrote
Why we set Desc.Width and Height to 0 and later we do not use "Desc" , but "Src.DataDescription" ?

Yes, now the Desc is unused and DataDescription is assigned as is. What could be the "side effects" mentioned in comments? Is there any reason to set Width and Height to 0?

I don't know the graph related code well but I can remove the unused part after getting confirmation from others.

Juha

Reply by email

Ondrej Pokorny
to Juha Manninen
Juha Manninen wrote 10 lines
On Wed, Sep 28, 2016 at 8:39 AM, LacaK via Lazarus wrote: > Why we set Desc.Width and Height to 0 and later we do not use "Desc" , but > "Src.DataDescription" ? Yes, now the Desc is unused and DataDescription is assigned as is. What could be the "side effects" mentioned in comments? Is there any reason to set Width and Height to 0? I don't know the graph related code well but I can remove the unused part after getting confirmation from others.

It looks like a left-over to me. It happens regularly also to myself during refactoring. IMO it can be removed - obviously there are not any side effects any more.

Ondrej

Reply by email

Juha Manninen
to Ondrej Pokorny
Ondrej Pokorny wrote
It looks like a left-over to me. It happens regularly also to myself during refactoring. IMO it can be removed - obviously there are not any side effects any more.

Ok, I will remove it ...

Juha

Reply by email