Ignore:
Timestamp:
Aug 17, 2016, 11:20:37 AM (8 years ago)
Author:
chronos
Message:
  • Modified: Do not initialize all forms at startup to save some memory.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormImportFormat.pas

    r31 r95  
    8080  NewImportPattern: TImportPattern;
    8181begin
    82   NewImportPattern := TImportPattern.Create;
    83   FormImportPattern.Load(NewImportPattern);
    84   if FormImportPattern.ShowModal = mrOk then begin
    85     FormImportPattern.Save(NewImportPattern);
    86     ImportFormat.ItemPatterns.Add(NewImportPattern);
    87     NewImportPattern := nil;
    88     ReloadList;
    89   end;
    90   if Assigned(NewImportPattern) then NewImportPattern.Free;
    91 end;
    92 
    93 procedure TFormImportFormat.AModifyExecute(Sender: TObject);
    94 var
    95   NewImportPattern: TImportPattern;
    96 begin
    97   if Assigned(ListViewItemRules.Selected) then begin
     82  FormImportPattern := TFormImportPattern.Create(Self);
     83  try
    9884    NewImportPattern := TImportPattern.Create;
    99     NewImportPattern.Assign(ListViewItemRules.Selected.Data);
    10085    FormImportPattern.Load(NewImportPattern);
    10186    if FormImportPattern.ShowModal = mrOk then begin
    10287      FormImportPattern.Save(NewImportPattern);
    103       TImportPattern(ListViewItemRules.Selected.Data).Assign(NewImportPattern);
     88      ImportFormat.ItemPatterns.Add(NewImportPattern);
     89      NewImportPattern := nil;
    10490      ReloadList;
    10591    end;
    10692    if Assigned(NewImportPattern) then NewImportPattern.Free;
     93  finally
     94    FreeAndNil(FormImportPattern);
     95  end;
     96end;
     97
     98procedure TFormImportFormat.AModifyExecute(Sender: TObject);
     99var
     100  NewImportPattern: TImportPattern;
     101begin
     102  FormImportPattern := TFormImportPattern.Create(Self);
     103  try
     104    if Assigned(ListViewItemRules.Selected) then begin
     105      NewImportPattern := TImportPattern.Create;
     106      NewImportPattern.Assign(ListViewItemRules.Selected.Data);
     107      FormImportPattern.Load(NewImportPattern);
     108      if FormImportPattern.ShowModal = mrOk then begin
     109        FormImportPattern.Save(NewImportPattern);
     110        TImportPattern(ListViewItemRules.Selected.Data).Assign(NewImportPattern);
     111        ReloadList;
     112      end;
     113      if Assigned(NewImportPattern) then NewImportPattern.Free;
     114    end;
     115  finally
     116    FreeAndNil(FormImportPattern);
    107117  end;
    108118end;
Note: See TracChangeset for help on using the changeset viewer.