if FItems<>nil then  FItems.Free;

does nothing more than FItems.Free

There is nothing wrong in that line of code - the items list is being
freed - if you are getting an exception there, it might indicate that you
are either freeing the menu twice, or there might have been some memory
corruption.

----- Original Message -----
From: "Alistair George" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Thursday, November 13, 2003 11:32 AM
Subject: [DUG]: Menus.pas Delphi 5 'Attempt to free a non-existing resource'


> Hi all.
> I have found a destroy resource problem which is indicated to be in
menus.pas.
>
> destructor TMenuItem.Destroy;
> begin
>   ShortCutItems.ClearItem(Self);
>   if FParent <> nil then
>   begin
>     FParent.Remove(Self);
>     FParent := nil;
>   end;
>   while Count > 0 do Items[0].Free;
>   if FHandle <> 0 then
>   begin
>     MergeWith(nil);
>     DestroyMenu(FHandle);
>   end;
> //The offending line is 'FItems.Free;' which I changed to below
>   if FItems<>nil then  FItems.Free;
>   FreeAndNil(FActionLink);
>   FreeAndNil(FImageChangeLink);
>   if FCommand <> 0 then CommandPool[FCommand] := False;
>   if Assigned(FBitmap) then FBitmap.Free;
>   inherited Destroy;
> end;
>
> but by changing the line to that creates a different problem.
> can you suggest what the correct way to free 'Fitems' would be given the
> circumstances thanks.
> Alistair+
>
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to