mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 20:29:12 +02:00
Converter: cache unit paths using OnIdle handler.
git-svn-id: trunk@27384 -
This commit is contained in:
parent
40bf83e108
commit
8e3631c047
@ -138,6 +138,8 @@ type
|
|||||||
// Units that are found and will be added to project and converted.
|
// Units that are found and will be added to project and converted.
|
||||||
fUnitsToAddToProject: TStringList;
|
fUnitsToAddToProject: TStringList;
|
||||||
fSettings: TConvertSettings;
|
fSettings: TConvertSettings;
|
||||||
|
fDoneScan: Boolean;
|
||||||
|
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
||||||
function ConvertSub: TModalResult;
|
function ConvertSub: TModalResult;
|
||||||
procedure CleanUpCompilerOptionsSearchPaths(Options: TBaseCompilerOptions);
|
procedure CleanUpCompilerOptionsSearchPaths(Options: TBaseCompilerOptions);
|
||||||
procedure SetCompilerModeForDefineTempl(DefTempl: TDefineTemplate);
|
procedure SetCompilerModeForDefineTempl(DefTempl: TDefineTemplate);
|
||||||
@ -519,7 +521,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
// Create a form file name based on the unit file name.
|
// Create a form file name based on the unit file name.
|
||||||
LfmFilename:=fSettings.DelphiToLazFilename(fOrigUnitFilename, '.lfm',
|
LfmFilename:=fSettings.DelphiToLazFilename(fOrigUnitFilename, '.lfm',
|
||||||
cdtlufRenameLowercase in fFlags);
|
cdtlufRenameLowercase in fFlags);
|
||||||
if DfmFilename<>'' then begin
|
if DfmFilename<>'' then begin
|
||||||
if FileExistsUTF8(LfmFilename) then
|
if FileExistsUTF8(LfmFilename) then
|
||||||
if (FileAgeUTF8(LfmFilename)<FileAgeUTF8(DfmFilename)) then
|
if (FileAgeUTF8(LfmFilename)<FileAgeUTF8(DfmFilename)) then
|
||||||
@ -871,8 +873,6 @@ begin
|
|||||||
fAllMissingUnits.Sorted:=true;
|
fAllMissingUnits.Sorted:=true;
|
||||||
fUnitsToAddToProject:=TStringList.Create;
|
fUnitsToAddToProject:=TStringList.Create;
|
||||||
fPrevSelectedPath:=fSettings.MainPath;
|
fPrevSelectedPath:=fSettings.MainPath;
|
||||||
// Scan unit files a level above project path. Used later for missing units.
|
|
||||||
CacheUnitsInPath(TrimFilename(fSettings.MainPath+'../'));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TConvertDelphiPBase.Destroy;
|
destructor TConvertDelphiPBase.Destroy;
|
||||||
@ -885,13 +885,24 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TConvertDelphiPBase.OnIdle(Sender: TObject; var Done: Boolean);
|
||||||
|
begin
|
||||||
|
if not fDoneScan then begin
|
||||||
|
CacheUnitsInPath(TrimFilename(fSettings.MainPath+'../'));
|
||||||
|
fDoneScan:=True;
|
||||||
|
end;
|
||||||
|
Done:=True;
|
||||||
|
end;
|
||||||
|
|
||||||
// Creates or updates a lazarus project (.lpi+.lpr) or package.
|
// Creates or updates a lazarus project (.lpi+.lpr) or package.
|
||||||
function TConvertDelphiPBase.Convert: TModalResult;
|
function TConvertDelphiPBase.Convert: TModalResult;
|
||||||
begin
|
begin
|
||||||
IDEMessagesWindow.Clear;
|
IDEMessagesWindow.Clear;
|
||||||
|
Application.AddOnIdleHandler(@OnIdle, False);
|
||||||
// Get settings from user.
|
// Get settings from user.
|
||||||
Result:=fSettings.RunForm;
|
Result:=fSettings.RunForm;
|
||||||
if Result=mrOK then begin
|
Application.RemoveOnIdleHandler(@OnIdle);
|
||||||
|
if (Result=mrOK) and fDoneScan then begin
|
||||||
// create/open lazarus project or package file
|
// create/open lazarus project or package file
|
||||||
fLazPFilename:=fSettings.DelphiToLazFilename(fOrigPFilename, fLazPSuffix, false);
|
fLazPFilename:=fSettings.DelphiToLazFilename(fOrigPFilename, fLazPSuffix, false);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ object ConvertSettingsForm: TConvertSettingsForm
|
|||||||
object MissingStuffGroupBox: TGroupBox
|
object MissingStuffGroupBox: TGroupBox
|
||||||
AnchorSideTop.Control = SettingsGroupBox
|
AnchorSideTop.Control = SettingsGroupBox
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideBottom.Control = ButtonPanel
|
AnchorSideBottom.Control = ButtonPanel1
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 213
|
Height = 213
|
||||||
Top = 219
|
Top = 219
|
||||||
@ -237,7 +237,7 @@ object ConvertSettingsForm: TConvertSettingsForm
|
|||||||
State = cbChecked
|
State = cbChecked
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object ButtonPanel: TButtonPanel
|
object ButtonPanel1: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 39
|
Height = 39
|
||||||
Top = 438
|
Top = 438
|
||||||
|
@ -39,16 +39,20 @@ type
|
|||||||
|
|
||||||
TConvertTarget = (ctLazarus, ctLazarusWin, ctLazarusAndDelphi);
|
TConvertTarget = (ctLazarus, ctLazarusWin, ctLazarusAndDelphi);
|
||||||
|
|
||||||
|
TConvertSettingsForm = class;
|
||||||
|
|
||||||
{ TConvertSettings }
|
{ TConvertSettings }
|
||||||
|
|
||||||
TConvertSettings = class
|
TConvertSettings = class
|
||||||
private
|
private
|
||||||
|
fEnabled: Boolean;
|
||||||
fTitle: String; // Used for form caption.
|
fTitle: String; // Used for form caption.
|
||||||
// Unit, Project or Package top file and path.
|
// Unit, Project or Package top file and path.
|
||||||
fMainFilename: String;
|
fMainFilename: String;
|
||||||
fMainPath: String;
|
fMainPath: String;
|
||||||
// Persistent storage in XML or some other format.
|
// Persistent storage in XML or some other format.
|
||||||
fConfigStorage: TConfigStorage;
|
fConfigStorage: TConfigStorage;
|
||||||
|
fSettingsForm: TConvertSettingsForm;
|
||||||
// Actual user settings.
|
// Actual user settings.
|
||||||
fBackupFiles: boolean;
|
fBackupFiles: boolean;
|
||||||
fTarget: TConvertTarget;
|
fTarget: TConvertTarget;
|
||||||
@ -67,6 +71,7 @@ type
|
|||||||
fVisualOffsets: TVisualOffsets;
|
fVisualOffsets: TVisualOffsets;
|
||||||
// Getter / setter:
|
// Getter / setter:
|
||||||
function GetBackupPath: String;
|
function GetBackupPath: String;
|
||||||
|
procedure SetEnabled(const AValue: Boolean);
|
||||||
procedure SetMainFilename(const AValue: String);
|
procedure SetMainFilename(const AValue: String);
|
||||||
public
|
public
|
||||||
constructor Create(const ATitle: string);
|
constructor Create(const ATitle: string);
|
||||||
@ -92,6 +97,7 @@ type
|
|||||||
property MainFilename: String read fMainFilename write SetMainFilename;
|
property MainFilename: String read fMainFilename write SetMainFilename;
|
||||||
property MainPath: String read fMainPath;
|
property MainPath: String read fMainPath;
|
||||||
property BackupPath: String read GetBackupPath;
|
property BackupPath: String read GetBackupPath;
|
||||||
|
property Enabled: Boolean read fEnabled write SetEnabled;
|
||||||
|
|
||||||
property BackupFiles: boolean read fBackupFiles;
|
property BackupFiles: boolean read fBackupFiles;
|
||||||
property Target: TConvertTarget read fTarget;
|
property Target: TConvertTarget read fTarget;
|
||||||
@ -113,7 +119,7 @@ type
|
|||||||
PropRemoveAutoCheckBox: TCheckBox;
|
PropRemoveAutoCheckBox: TCheckBox;
|
||||||
UnitReplaceAutoCheckBox: TCheckBox;
|
UnitReplaceAutoCheckBox: TCheckBox;
|
||||||
BackupCheckBox: TCheckBox;
|
BackupCheckBox: TCheckBox;
|
||||||
ButtonPanel: TButtonPanel;
|
ButtonPanel1: TButtonPanel;
|
||||||
FuncReplaceEnableCheckBox: TCheckBox;
|
FuncReplaceEnableCheckBox: TCheckBox;
|
||||||
VisualOffsEnableCheckBox: TCheckBox;
|
VisualOffsEnableCheckBox: TCheckBox;
|
||||||
Label1: TLabel;
|
Label1: TLabel;
|
||||||
@ -336,6 +342,8 @@ begin
|
|||||||
fTitle:=ATitle;
|
fTitle:=ATitle;
|
||||||
fMainFilename:='';
|
fMainFilename:='';
|
||||||
fMainPath:='';
|
fMainPath:='';
|
||||||
|
fEnabled:=True;
|
||||||
|
fSettingsForm:=Nil;
|
||||||
fReplaceUnits:=TStringToStringTree.Create(false);
|
fReplaceUnits:=TStringToStringTree.Create(false);
|
||||||
fReplaceTypes:=TStringToStringTree.Create(false);
|
fReplaceTypes:=TStringToStringTree.Create(false);
|
||||||
fReplaceFuncs:=TFuncsAndCategories.Create;
|
fReplaceFuncs:=TFuncsAndCategories.Create;
|
||||||
@ -469,35 +477,34 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TConvertSettings.RunForm: TModalResult;
|
function TConvertSettings.RunForm: TModalResult;
|
||||||
var
|
|
||||||
SettingsForm: TConvertSettingsForm;
|
|
||||||
begin
|
begin
|
||||||
SettingsForm:=TConvertSettingsForm.Create(nil, Self);
|
fSettingsForm:=TConvertSettingsForm.Create(nil, Self);
|
||||||
with SettingsForm do
|
|
||||||
try
|
try
|
||||||
Caption:=fTitle;
|
with fSettingsForm do begin
|
||||||
ProjectPathEdit.Text:=fMainPath;
|
Caption:=fTitle;
|
||||||
// Settings --> UI. Loaded from ConfigSettings earlier.
|
ProjectPathEdit.Text:=fMainPath;
|
||||||
BackupCheckBox.Checked :=fBackupFiles;
|
// Settings --> UI. Loaded from ConfigSettings earlier.
|
||||||
TargetRadioGroup.ItemIndex :=integer(fTarget);
|
BackupCheckBox.Checked :=fBackupFiles;
|
||||||
SameDFMCheckBox.Checked :=fSameDFMFile;
|
TargetRadioGroup.ItemIndex :=integer(fTarget);
|
||||||
PropRemoveAutoCheckBox.Checked :=fAutoRemoveProperties;
|
SameDFMCheckBox.Checked :=fSameDFMFile;
|
||||||
UnitReplaceAutoCheckBox.Checked :=fAutoReplaceUnits;
|
PropRemoveAutoCheckBox.Checked :=fAutoRemoveProperties;
|
||||||
FuncReplaceEnableCheckBox.Checked:=fEnableReplaceFuncs;
|
UnitReplaceAutoCheckBox.Checked :=fAutoReplaceUnits;
|
||||||
VisualOffsEnableCheckBox.Checked :=fEnableVisualOffs;
|
FuncReplaceEnableCheckBox.Checked:=fEnableReplaceFuncs;
|
||||||
Result:=ShowModal; // Let the user change settings in a form.
|
VisualOffsEnableCheckBox.Checked :=fEnableVisualOffs;
|
||||||
if Result=mrOK then begin
|
Result:=ShowModal; // Let the user change settings in a form.
|
||||||
// UI --> Settings. Will be saved to ConfigSettings later.
|
if Result=mrOK then begin
|
||||||
fBackupFiles :=BackupCheckBox.Checked;
|
// UI --> Settings. Will be saved to ConfigSettings later.
|
||||||
fTarget :=TConvertTarget(TargetRadioGroup.ItemIndex);
|
fBackupFiles :=BackupCheckBox.Checked;
|
||||||
fSameDFMFile :=SameDFMCheckBox.Checked;
|
fTarget :=TConvertTarget(TargetRadioGroup.ItemIndex);
|
||||||
fAutoRemoveProperties:=PropRemoveAutoCheckBox.Checked;
|
fSameDFMFile :=SameDFMCheckBox.Checked;
|
||||||
fAutoReplaceUnits :=UnitReplaceAutoCheckBox.Checked;
|
fAutoRemoveProperties:=PropRemoveAutoCheckBox.Checked;
|
||||||
fEnableReplaceFuncs :=FuncReplaceEnableCheckBox.Checked;
|
fAutoReplaceUnits :=UnitReplaceAutoCheckBox.Checked;
|
||||||
fEnableVisualOffs :=VisualOffsEnableCheckBox.Checked;
|
fEnableReplaceFuncs :=FuncReplaceEnableCheckBox.Checked;
|
||||||
|
fEnableVisualOffs :=VisualOffsEnableCheckBox.Checked;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
Free;
|
FreeAndNil(fSettingsForm);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -587,6 +594,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TConvertSettings.SetEnabled(const AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if fEnabled=AValue then exit;
|
||||||
|
fEnabled:=AValue;
|
||||||
|
if Assigned(fSettingsForm) then
|
||||||
|
fSettingsForm.ButtonPanel1.Enabled:=fEnabled; // OKButton
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TConvertSettingsForm }
|
{ TConvertSettingsForm }
|
||||||
|
|
||||||
@ -610,9 +625,9 @@ begin
|
|||||||
BackupCheckBox.Caption:=lisBackupChangedFiles;
|
BackupCheckBox.Caption:=lisBackupChangedFiles;
|
||||||
BackupCheckBox.Hint:=lisBackupHint;
|
BackupCheckBox.Hint:=lisBackupHint;
|
||||||
|
|
||||||
ButtonPanel.OKButton.Caption:=lisStartConversion;
|
ButtonPanel1.OKButton.Caption:=lisStartConversion;
|
||||||
ButtonPanel.HelpButton.Caption:=lisMenuHelp;
|
ButtonPanel1.HelpButton.Caption:=lisMenuHelp;
|
||||||
ButtonPanel.CancelButton.Caption:=dlgCancel;
|
ButtonPanel1.CancelButton.Caption:=dlgCancel;
|
||||||
|
|
||||||
SameDFMCheckBox.Caption:=lisConvUseSameDFM;
|
SameDFMCheckBox.Caption:=lisConvUseSameDFM;
|
||||||
SameDFMCheckBox.Hint:=lisConvUseSameDFMHint;
|
SameDFMCheckBox.Hint:=lisConvUseSameDFMHint;
|
||||||
|
Loading…
Reference in New Issue
Block a user