[delphizip] Re: DelphiZip Error

  • From: Russell Peters <rpeters@xxxxxxxxxxxxx>
  • To: delphizip@xxxxxxxxxxxxx
  • Date: Fri, 26 Sep 2014 14:55:12 +1000

On 26/09/2014 10:13 AM, Paul Nauta wrote:
> Hello All,
>   
>
> I use DelphiZip already for 7 years without problems, thanks for all your
> great work!
>
> So far I used Delphi-XE2 with ZipMaster 1.9.1.0010
>
> No I switched to Delphi-XE7 and ZipMaster 1.9.2.0010
>
> But this is the first time I see an issue:
>
>   
>
> I have my own derived type:
>
>    TPKN_ZipMaster = CLASS( TZipMaster )
>
>   
>
> The create looks as follows:
>
> CONSTRUCTOR TPKN_ZipMaster.Create( AOwner : TComponent );
>
> BEGIN
>
>    INHERITED;
>
>    FCaptionPrefix    := '';
>
>    FProgressBar      := TPKN_ProgressBar.Create( Self );
>
>    FDisplayModes     := [ dmShowErrors, dmShowRunning ];
>
>    OnProgress        := ZipProgress;
>
>    OnMessage         := ExecuteMessage;
>
>    Verbose           := True;
>
> END;
>
>   
>
> The problem is in the Verbose setting. It generates an access violation in:
>
> function TCustomZipMaster.GetState: TZMStates;
>
> begin
>
>    Result := TZMCommand(FBody).State;
>
> end;
>
>   
>
> Reason is that FBody is still nil, as it is only set in the
> AfterConstruction event
>
> Please have a look at this
>
>   
>
>   
>
> Paul Nauta
>
>   
>
>
>
> -----------
> To unsubscribe from this list, send an empty e-mail
> message to:
>    delphizip-request@xxxxxxxxxxxxx
> and put the word unsubscribe in the subject.
I can see your problem, if you move setting ZipMaster settings to the 
AfterConstruction  event it should work but maybe it would be safer for 
me to override the constructor and remove the AfterConstruction in 
TCustomZipMaster.

   // the main component
   TCustomZipMaster = class(TComponent)
...
   public
     constructor Create(AOwner: TComponent); override;   // << add
  ...
//    procedure AfterConstruction; override;   // << remove
     procedure BeforeDestruction; override;
...

constructor TCustomZipMaster.Create(AOwner: TComponent);
begin
   inherited;
   FBody := TZMCommand.Create(Self);
   FFSpecArgs := TZMStringList.Create;
   FFSpecArgsExcl := TZMStringList.Create;
   FHandle := Application.Handle;
end;
...
//procedure TCustomZipMaster.AfterConstruction;
//begin
//  inherited;
//  FBody := TZMCommand.Create(Self);
//  FFSpecArgs := TZMStringList.Create;
//  FFSpecArgsExcl := TZMStringList.Create;
//  FHandle := Application.Handle;
//end;

I will make this change for the next build, I had not planned on anyone 
overriding the constructor (which of course is a valid way of doing things).
Russell Peters
-----------
To unsubscribe from this list, send an empty e-mail 
message to:
  delphizip-request@xxxxxxxxxxxxx 
and put the word unsubscribe in the subject.

Other related posts: