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

    r86 r95  
    187187  NewImportSource := TImportSource.Create;
    188188  NewImportSource.Sources := ImportSources;
    189   FormImportSource.Load(NewImportSource);
    190   if FormImportSource.ShowModal = mrOk then begin
    191     FormImportSource.Save(NewImportSource);
    192     if not Assigned(ImportSources.SearchByName(NewImportSource.Name)) then begin;
    193       ImportSources.Add(NewImportSource);
    194       NewImportSource := nil;
    195       Core.AcronymDb.Modified := True;
    196       UpdateList;
    197     end else ShowMessage(Format(SImportSourceAlreadyExists, [NewImportSource.Name]));
    198   end;
    199   if Assigned(NewImportSource) then NewImportSource.Free;
     189  FormImportSource := TFormImportSource.Create(Self);
     190  try
     191    FormImportSource.Load(NewImportSource);
     192    if FormImportSource.ShowModal = mrOk then begin
     193      FormImportSource.Save(NewImportSource);
     194      if not Assigned(ImportSources.SearchByName(NewImportSource.Name)) then begin;
     195        ImportSources.Add(NewImportSource);
     196        NewImportSource := nil;
     197        Core.AcronymDb.Modified := True;
     198        UpdateList;
     199      end else ShowMessage(Format(SImportSourceAlreadyExists, [NewImportSource.Name]));
     200    end;
     201    if Assigned(NewImportSource) then NewImportSource.Free;
     202  finally
     203    FreeAndNil(FormImportSource);
     204  end;
    200205end;
    201206
     
    227232    NewImportSource := TImportSource.Create;
    228233    NewImportSource.Assign(ListView1.Selected.Data);
    229     FormImportSource.Load(NewImportSource);
    230     if FormImportSource.ShowModal = mrOk then begin
    231       FormImportSource.Save(NewImportSource);
    232       if (NewImportSource.Name <> TImportSource(ListView1.Selected.Data).Name) then begin
    233         if not Assigned(ImportSources.SearchByName(NewImportSource.Name)) then begin;
     234    FormImportSource := TFormImportSource.Create(Self);
     235    try
     236      FormImportSource.Load(NewImportSource);
     237      if FormImportSource.ShowModal = mrOk then begin
     238        FormImportSource.Save(NewImportSource);
     239        if (NewImportSource.Name <> TImportSource(ListView1.Selected.Data).Name) then begin
     240          if not Assigned(ImportSources.SearchByName(NewImportSource.Name)) then begin;
     241            TImportSource(ListView1.Selected.Data).Assign(NewImportSource);
     242            Core.AcronymDb.Modified := True;
     243            UpdateList;
     244          end else ShowMessage(Format(SImportSourceAlreadyExists, [NewImportSource.Name]));
     245        end else begin
    234246          TImportSource(ListView1.Selected.Data).Assign(NewImportSource);
    235247          Core.AcronymDb.Modified := True;
    236248          UpdateList;
    237         end else ShowMessage(Format(SImportSourceAlreadyExists, [NewImportSource.Name]));
    238       end else begin
    239         TImportSource(ListView1.Selected.Data).Assign(NewImportSource);
    240         Core.AcronymDb.Modified := True;
    241         UpdateList;
     249        end;
    242250      end;
    243     end;
    244     if Assigned(NewImportSource) then NewImportSource.Free;
     251      if Assigned(NewImportSource) then NewImportSource.Free;
     252    finally
     253      FreeAndNil(FormImportSource);
     254    end;
    245255  end;
    246256end;
Note: See TracChangeset for help on using the changeset viewer.