[fpc-devel] [PATCH] patch for zipper.pp

Michael Van Canneyt michael at freepascal.org
Wed Jul 29 10:07:42 CEST 2009



On Wed, 29 Jul 2009, Micha Nelissen wrote:

> Andrew Haines wrote:
>> procedure TForm1. at UnZipCustomOutput(Sender: TObject; var AStream:
>>             TStream; AItem: TFullZipFileEntry; AClosing: Boolean);
>> begin
>>   if AClosing = False then
>>   begin
>>     AStream := TMemoryStream.Create;
>>   end
>
> Do you mind if I say I think this is a very weird event handler?
>
> What is the behaviour? How many times is it called? What does AClosing mean? 
> How do I know I don't have a memory leak?
>
> Why an event handler and not a property? A CustomStream property where 
> non-nil means use this stream, if nil then default old behaviour e.g.

Well, maybe a bit awkward, but the handler makes sense.

Your Customstream is not possible, because multiple files must be extracted
to different streams.

The handler is called 2 times:
- Once to create the stream (aclosing=false)
- Once when the data has been written to the steam. (AClosing=true)

Maybe it had been better to create 2 events:
- OnCreateStream
- OnDestroyStream (optional, if not set the component frees the stream)

What do you think ?

Michael.



More information about the fpc-devel mailing list