mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-27 20:13:50 +02:00
menueditor: fix for memory leaks
git-svn-id: trunk@21763 -
This commit is contained in:
parent
34fedff730
commit
1d7ba22be7
@ -114,6 +114,7 @@ type
|
||||
protected
|
||||
procedure PersistentDeleting(APersistent: TPersistent);
|
||||
function SearchItemByPanel(DesignerMenuItem: PDesignerMenuItem; APanel: TPanel): PDesignerMenuItem;
|
||||
procedure ClearAllMenus;
|
||||
public
|
||||
// Constructor and destructor
|
||||
constructor CreateWithMenu(AOwner: TComponent; AMenu: TMenu);
|
||||
@ -213,7 +214,9 @@ end;
|
||||
procedure TDesignerMainMenu.SetRoot(const AValue: PDesignerMenuItem);
|
||||
begin
|
||||
if FRoot <> nil then
|
||||
begin
|
||||
Dispose(FRoot);
|
||||
end;
|
||||
FRoot := AValue;
|
||||
end;
|
||||
|
||||
@ -315,7 +318,7 @@ destructor TDesignerMainMenu.Destroy;
|
||||
begin
|
||||
if GlobalDesignHook<>nil then
|
||||
GlobalDesignHook.RemoveAllHandlersForObject(Self);
|
||||
Root := nil;
|
||||
ClearAllMenus;
|
||||
FreeAndNil(XMLConfig);
|
||||
inherited Destroy;
|
||||
end;
|
||||
@ -968,6 +971,21 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TDesignerMainMenu.ClearAllMenus;
|
||||
|
||||
procedure DeleteRecursive(var AMenu: PDesignerMenuItem);
|
||||
begin
|
||||
if not Assigned(AMenu) then Exit;
|
||||
if Assigned(AMenu^.NextItem) then DeleteRecursive(AMenu^.NextItem);
|
||||
if Assigned(AMenu^.SubMenu) then DeleteRecursive(AMenu^.SubMenu);
|
||||
Dispose(AMenu);
|
||||
AMenu:=nil;
|
||||
end;
|
||||
|
||||
begin
|
||||
DeleteRecursive(fRoot);
|
||||
end;
|
||||
|
||||
// -----------------------------------------------------------------//
|
||||
// Insert From Template has been selected from context menu --------//
|
||||
// -----------------------------------------------------------------//
|
||||
|
Loading…
Reference in New Issue
Block a user