Changeset 105 for trunk/Packages/Common


Ignore:
Timestamp:
Feb 10, 2022, 11:51:03 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Optimized update of recent opened files menu.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/ULastOpenedList.pas

    r21 r105  
    8484destructor TLastOpenedList.Destroy;
    8585begin
    86   Items.Free;
     86  FreeAndNil(Items);
    8787  inherited;
    8888end;
     
    9494begin
    9595  if Assigned(MenuItem) then begin
    96     MenuItem.Clear;
     96    while MenuItem.Count > Items.Count do
     97      MenuItem.Delete(MenuItem.Count - 1);
     98    while MenuItem.Count < Items.Count do begin
     99      NewMenuItem := TMenuItem.Create(MenuItem);
     100      MenuItem.Add(NewMenuItem);
     101    end;
    97102    for I := 0 to Items.Count - 1 do begin
    98       NewMenuItem := TMenuItem.Create(MenuItem);
    99       NewMenuItem.Caption := Items[I];
    100       NewMenuItem.OnClick := ClickAction;
    101       MenuItem.Add(NewMenuItem);
     103      MenuItem.Items[I].Caption := Items[I];
     104      MenuItem.Items[I].OnClick := ClickAction;
    102105    end;
    103106  end;
Note: See TracChangeset for help on using the changeset viewer.