33 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
44 * obtain one at https://mozilla.org/MPL/2.0/
55 *
6- * Copyright (C) 2005-2021 , Peter Johnson (gravatar.com/delphidabbler).
6+ * Copyright (C) 2005-2022 , Peter Johnson (gravatar.com/delphidabbler).
77 *
88 * Implements a dialogue box where the user can configure the Pascal compilers
99 * that are to be used by CodeSnip.
@@ -122,7 +122,12 @@ implementation
122122
123123uses
124124 // Project
125- Compilers.UCompilers, IntfCommon, UCtrlArranger, UExeFileType, UFontHelper,
125+ Compilers.UAutoDetect,
126+ Compilers.UCompilers,
127+ IntfCommon,
128+ UCtrlArranger,
129+ UExeFileType,
130+ UFontHelper,
126131 UMessageBox;
127132
128133
@@ -148,8 +153,6 @@ procedure TCompilersDlg.ArrangeForm;
148153end ;
149154
150155procedure TCompilersDlg.btnDetectClick (Sender: TObject);
151- var
152- Compiler: ICompiler; // refers to each compiler
153156resourcestring
154157 // Text displayed in confirmation box
155158 sOKToDetect = ' Detected compiler file names will overwrite any existing '
@@ -159,19 +162,14 @@ procedure TCompilersDlg.btnDetectClick(Sender: TObject);
159162 Exit;
160163 // Record any changes to current compiler
161164 UpdateCurrentCompiler;
162- // Loop thru all compilers attempting to detect exe files
163- for Compiler in fLocalCompilers do
164- begin
165- if Supports(Compiler, ICompilerAutoDetect) then
165+ // Register any available compilers
166+ TCompilerAutoDetect.RegisterCompilers(fLocalCompilers,
167+ procedure (RegisteredCompiler: ICompiler)
166168 begin
167- if (Compiler as ICompilerAutoDetect).DetectExeFile then
168- begin
169- // Update currently displayed compiler details
170- if Compiler.GetID = fCurCompiler.GetID then
171- UpdateEditFrames;
172- end ;
173- end ;
174- end ;
169+ if RegisteredCompiler.GetID = fCurCompiler.GetID then
170+ UpdateEditFrames;
171+ end
172+ );
175173 // Redisplay compiler list and current compiler title to reflect any changes
176174 fCompListMgr.Refresh;
177175 fBannerMgr.Refresh;
@@ -234,20 +232,21 @@ class function TCompilersDlg.Execute(AOwner: TComponent;
234232 const ACompilers: ICompilers): Boolean;
235233var
236234 Persister: IPersistCompilers; // object used to save object to storage
235+ Dlg: TCompilersDlg; // dialogue box instance
237236begin
238- with InternalCreate(AOwner) do
239- try
240- (fLocalCompilers as IAssignable).Assign(ACompilers);
241- Result := ShowModal = mrOK;
242- if Result then
243- begin
244- (ACompilers as IAssignable).Assign(fLocalCompilers);
245- Persister := TPersistCompilers.Create;
246- Persister.Save(ACompilers);
247- end ;
248- finally
249- Free;
237+ Dlg := InternalCreate(AOwner);
238+ try
239+ (Dlg.fLocalCompilers as IAssignable).Assign(ACompilers);
240+ Result := Dlg.ShowModal = mrOK;
241+ if Result then
242+ begin
243+ (ACompilers as IAssignable).Assign(Dlg.fLocalCompilers);
244+ Persister := TPersistCompilers.Create;
245+ Persister.Save(ACompilers);
250246 end ;
247+ finally
248+ Dlg.Free;
249+ end ;
251250end ;
252251
253252procedure TCompilersDlg.FormCreate (Sender: TObject);
0 commit comments