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

    r86 r95  
    112112  NewImportFormat := TImportFormat.Create;
    113113  NewImportFormat.Formats := ImportFormats;
    114   FormImportFormat.Load(NewImportFormat);
    115   if FormImportFormat.ShowModal = mrOk then begin
    116     FormImportFormat.Save(NewImportFormat);
    117     if not Assigned(ImportFormats.SearchByName(NewImportFormat.Name)) then begin;
    118       ImportFormats.Add(NewImportFormat);
    119       NewImportFormat := nil;
    120       Core.AcronymDb.Modified := True;
    121       UpdateList;
    122     end else ShowMessage(Format(SImportFormatAlreadyExists, [NewImportFormat.Name]));
     114  FormImportFormat := TFormImportFormat.Create(Self);
     115  try
     116    FormImportFormat.Load(NewImportFormat);
     117    if FormImportFormat.ShowModal = mrOk then begin
     118      FormImportFormat.Save(NewImportFormat);
     119      if not Assigned(ImportFormats.SearchByName(NewImportFormat.Name)) then begin;
     120        ImportFormats.Add(NewImportFormat);
     121        NewImportFormat := nil;
     122        Core.AcronymDb.Modified := True;
     123        UpdateList;
     124      end else ShowMessage(Format(SImportFormatAlreadyExists, [NewImportFormat.Name]));
     125    end;
     126    if Assigned(NewImportFormat) then NewImportFormat.Free;
     127  finally
     128    FreeAndNil(FormImportFormat);
    123129  end;
    124   if Assigned(NewImportFormat) then NewImportFormat.Free;
    125130end;
    126131
     
    132137    NewImportFormat := TImportFormat.Create;
    133138    NewImportFormat.Assign(ListView1.Selected.Data);
    134     FormImportFormat.Load(NewImportFormat);
    135     if FormImportFormat.ShowModal = mrOk then begin
    136       FormImportFormat.Save(NewImportFormat);
    137       if (NewImportFormat.Name <> TImportFormat(ListView1.Selected.Data).Name) then begin
    138         if not Assigned(ImportFormats.SearchByName(NewImportFormat.Name)) then begin;
     139    FormImportFormat := TFormImportFormat.Create(Self);
     140    try
     141      FormImportFormat.Load(NewImportFormat);
     142      if FormImportFormat.ShowModal = mrOk then begin
     143        FormImportFormat.Save(NewImportFormat);
     144        if (NewImportFormat.Name <> TImportFormat(ListView1.Selected.Data).Name) then begin
     145          if not Assigned(ImportFormats.SearchByName(NewImportFormat.Name)) then begin;
     146            TImportFormat(ListView1.Selected.Data).Assign(NewImportFormat);
     147            Core.AcronymDb.Modified := True;
     148            UpdateList;
     149          end else ShowMessage(Format(SImportFormatAlreadyExists, [NewImportFormat.Name]));
     150        end else begin
    139151          TImportFormat(ListView1.Selected.Data).Assign(NewImportFormat);
    140152          Core.AcronymDb.Modified := True;
    141153          UpdateList;
    142         end else ShowMessage(Format(SImportFormatAlreadyExists, [NewImportFormat.Name]));
    143       end else begin
    144         TImportFormat(ListView1.Selected.Data).Assign(NewImportFormat);
    145         Core.AcronymDb.Modified := True;
    146         UpdateList;
     154        end;
    147155      end;
     156      if Assigned(NewImportFormat) then NewImportFormat.Free;
     157    finally
     158      FreeAndNil(FormImportFormat);
    148159    end;
    149     if Assigned(NewImportFormat) then NewImportFormat.Free;
    150160  end;
    151161end;
Note: See TracChangeset for help on using the changeset viewer.