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/UFormImportSource.pas

    r89 r95  
    7272    NewImportFormat := TImportFormat.Create;
    7373    NewImportFormat.Assign(TImportFormat(ComboBox1.Items.Objects[ComboBox1.ItemIndex]));
    74     FormImportFormat.Load(NewImportFormat);
    75     if FormImportFormat.ShowModal = mrOk then begin
    76       FormImportFormat.Save(NewImportFormat);
    77       TImportFormat(ComboBox1.Items.Objects[ComboBox1.ItemIndex]).Assign(NewImportFormat);
    78       Core.AcronymDb.Modified := True;
    79       ComboBox1.Items.Strings[ComboBox1.ItemIndex] := NewImportFormat.Name;
     74    FormImportFormat := TFormImportFormat.Create(Self);
     75    try
     76      FormImportFormat.Load(NewImportFormat);
     77      if FormImportFormat.ShowModal = mrOk then begin
     78        FormImportFormat.Save(NewImportFormat);
     79        TImportFormat(ComboBox1.Items.Objects[ComboBox1.ItemIndex]).Assign(NewImportFormat);
     80        Core.AcronymDb.Modified := True;
     81        ComboBox1.Items.Strings[ComboBox1.ItemIndex] := NewImportFormat.Name;
     82      end;
     83      if Assigned(NewImportFormat) then NewImportFormat.Free;
     84    finally
     85      FreeAndNil(FormImportFormat);
    8086    end;
    81     if Assigned(NewImportFormat) then NewImportFormat.Free;
    8287  end;
    8388end;
     
    97102  I: Integer;
    98103begin
    99   FormCategorySelect.Load(ListBox1.Items);
    100   if FormCategorySelect.ShowModal = mrOk then begin
    101     for I := 0 to FormCategorySelect.ListBox1.Count - 1 do
    102       if FormCategorySelect.ListBox1.Selected[I] then begin
    103         ListBox1.Items.AddObject(FormCategorySelect.ListBox1.Items[I], FormCategorySelect.ListBox1.Items.Objects[I]);
    104       end;
     104  FormCategorySelect := TFormCategorySelect.Create(Self);
     105  try
     106    FormCategorySelect.Load(ListBox1.Items);
     107    if FormCategorySelect.ShowModal = mrOk then begin
     108      for I := 0 to FormCategorySelect.ListBox1.Count - 1 do
     109        if FormCategorySelect.ListBox1.Selected[I] then begin
     110          ListBox1.Items.AddObject(FormCategorySelect.ListBox1.Items[I], FormCategorySelect.ListBox1.Items.Objects[I]);
     111        end;
     112    end;
     113  finally
     114    FreeAndNil(FormCategorySelect);
    105115  end;
    106116end;
Note: See TracChangeset for help on using the changeset viewer.