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

    r91 r95  
    207207procedure TFormMain.AExportExecute(Sender: TObject);
    208208begin
    209   FormExport.ShowModal;
     209  FormExport := TFormExport.Create(Self);
     210  try
     211    FormExport.ShowModal;
     212  finally
     213    FreeAndNil(FormExport);
     214  end;
    210215end;
    211216
     
    281286procedure TFormMain.AImportExecute(Sender: TObject);
    282287begin
    283   FormImport.ShowModal;
    284   UpdateAcronymsList;
    285   UpdateInterface;
     288  FormImport := TFormImport.Create(Self);
     289  try
     290    FormImport.ShowModal;
     291    UpdateAcronymsList;
     292    UpdateInterface;
     293  finally
     294    FreeAndNil(FormImport);
     295  end;
    286296end;
    287297
     
    314324procedure TFormMain.ASettingsExecute(Sender: TObject);
    315325begin
    316   FormSettings.Load;
    317   if FormSettings.ShowModal = mrOk then begin
     326  FormSettings := TFormSettings.Create(Self);
     327  try
     328    FormSettings.Load;
     329    if FormSettings.ShowModal = mrOk then begin
    318330    FormSettings.Save;
    319     Core.SaveConfig;
     331      Core.SaveConfig;
     332    end;
     333  finally
     334    FreeAndNil(FormSettings);
    320335  end;
    321336end;
     
    323338procedure TFormMain.AShowAboutExecute(Sender: TObject);
    324339begin
    325   FormAbout.ShowModal;
     340  FormAbout := TFormAbout.Create(Self);
     341  try
     342    FormAbout.ShowModal;
     343  finally
     344    FreeAndNil(FormAbout);
     345  end;
    326346end;
    327347
    328348procedure TFormMain.AShowAcronymsExecute(Sender: TObject);
    329349begin
    330   FormAcronyms.ShowModal;
    331   UpdateAcronymsList;
    332   UpdateInterface;
     350  FormAcronyms := TFormAcronyms.Create(Self);
     351  try
     352    FormAcronyms.ShowModal;
     353    UpdateAcronymsList;
     354    UpdateInterface;
     355  finally
     356    FreeAndNil(FormAcronyms);
     357  end;
    333358end;
    334359
    335360procedure TFormMain.AShowCategoriesExecute(Sender: TObject);
    336361begin
    337   FormCategories.Categories := Core.AcronymDb.Categories;
    338   FormCategories.ShowModal;
    339   UpdateAcronymsList;
    340   UpdateInterface;
     362  FormCategories := TFormCategories.Create(Self);
     363  try
     364    FormCategories.Categories := Core.AcronymDb.Categories;
     365    FormCategories.ShowModal;
     366    UpdateAcronymsList;
     367    UpdateInterface;
     368  finally
     369    FreeAndNil(FormCategories);
     370  end;
    341371end;
    342372
     
    349379procedure TFormMain.AShowImportFormatsExecute(Sender: TObject);
    350380begin
    351   FormImportFormats.ImportFormats := Core.AcronymDb.ImportFormats;
    352   FormImportFormats.ShowModal;
    353   UpdateInterface;
     381  FormImportFormats := TFormImportFormats.Create(Self);
     382  try
     383    FormImportFormats.ImportFormats := Core.AcronymDb.ImportFormats;
     384    FormImportFormats.ShowModal;
     385    UpdateInterface;
     386  finally
     387    FreeAndNil(FormImportFormats);
     388  end;
    354389end;
    355390
    356391procedure TFormMain.AShowImportSourcesExecute(Sender: TObject);
    357392begin
    358   FormImportSources.ImportSources := Core.AcronymDb.ImportSources;
    359   FormImportSources.ShowModal;
    360   UpdateAcronymsList;
    361   UpdateInterface;
     393  FormImportSources := TFormImportSources.Create(Self);
     394  try
     395    FormImportSources.ImportSources := Core.AcronymDb.ImportSources;
     396    FormImportSources.ShowModal;
     397    UpdateAcronymsList;
     398    UpdateInterface;
     399  finally
     400    FreeAndNil(FormImportSources);
     401  end;
    362402end;
    363403
Note: See TracChangeset for help on using the changeset viewer.