mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 02:40:00 +01:00 
			
		
		
		
	handle external deletion of menuitems; note: deleting "root" menu item will cause a crash still
git-svn-id: trunk@9628 -
This commit is contained in:
		
							parent
							
								
									e07af6a39f
								
							
						
					
					
						commit
						88558ed640
					
				@ -101,6 +101,8 @@ type
 | 
			
		||||
    fDesignerPopupMenu: TPopupMenu;
 | 
			
		||||
    TemplateMenuForm: TTemplateMenuForm;
 | 
			
		||||
    function GetDesigner: TComponentEditorDesigner;
 | 
			
		||||
  protected
 | 
			
		||||
    procedure PersistentDeleting(APersistent: TPersistent);
 | 
			
		||||
  public
 | 
			
		||||
    // Constructor and destructor
 | 
			
		||||
    constructor CreateWithMenu(aOwner: TComponent; aMenu: TMenu);
 | 
			
		||||
@ -284,8 +286,10 @@ begin
 | 
			
		||||
  // designermenuitem
 | 
			
		||||
  GlobalDesignHook.AddHandlerModified(@OnDesignerModified);
 | 
			
		||||
  //GlobalDesignHook.AddHandlerPersistentAdded(@OnComponentAdded);
 | 
			
		||||
  GlobalDesignHook.AddHandlerPersistentDeleting(@PersistentDeleting);
 | 
			
		||||
 | 
			
		||||
  new(Root);
 | 
			
		||||
  fillchar(root^, sizeof(root^), #0);
 | 
			
		||||
  fMenu:=aMenu;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -377,7 +381,7 @@ begin
 | 
			
		||||
    GetDesigner.PropertyEditorHook.PersistentAdded(firstmenuitem, true);
 | 
			
		||||
    GetDesigner.Modified;
 | 
			
		||||
  end;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  prevtemp:=nil;
 | 
			
		||||
  for i:= 0 to fMenu.Items.Count-1 do
 | 
			
		||||
  begin
 | 
			
		||||
@ -447,6 +451,7 @@ procedure TDesignerMainMenu.Draw(MenuItem: PDesignerMenuItem; FormPanel,SubMenuP
 | 
			
		||||
var
 | 
			
		||||
  SubMenuDimensions: TRect;
 | 
			
		||||
begin
 | 
			
		||||
  if MenuItem^.SelfPanel = nil then exit;
 | 
			
		||||
  with MenuItem^.SelfPanel do
 | 
			
		||||
  begin
 | 
			
		||||
    if (fMenu is TPopupMenu) and (MenuItem^.Level = 1) then
 | 
			
		||||
@ -863,6 +868,17 @@ begin
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TDesignerMainMenu.PersistentDeleting(APersistent: TPersistent);
 | 
			
		||||
begin
 | 
			
		||||
  if APersistent is TMenuItem then
 | 
			
		||||
  begin
 | 
			
		||||
    DeleteItem(FindDesignerMenuItem(TMenuItem(APersistent)));
 | 
			
		||||
    SetCoordinates(POSITION_LEFT, POSITION_TOP, 0, Root);
 | 
			
		||||
    Parent.Invalidate;
 | 
			
		||||
  end;
 | 
			
		||||
  inherited;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
// -----------------------------------------------------------------//
 | 
			
		||||
// Insert From Template has been selected from context menu --------//
 | 
			
		||||
// -----------------------------------------------------------------//
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user