mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 07:29:25 +02:00
IDE: added some error handling to 'Resave forms with i18n' (ask user if he wants to retry or abort on read/write errors)
git-svn-id: trunk@52590 -
This commit is contained in:
parent
17018410ca
commit
2771d74068
@ -3391,6 +3391,7 @@ resourcestring
|
||||
lisLazBuildManageProfiles ='Manage Build Profiles';
|
||||
lisLazBuildProfile ='Profile to build';
|
||||
lisLazBuildErrorWritingFile = 'Error writing file';
|
||||
lisCannotWriteFile = 'Cannot write file %s';
|
||||
lisLazBuildUnableToWriteFile = 'Unable to write file "%s":%s';
|
||||
lisLazBuildNormalIDE = 'Normal IDE';
|
||||
lisLazBuildDebugIDE = 'Debug IDE';
|
||||
@ -4138,6 +4139,7 @@ resourcestring
|
||||
lisPkgMangUnableToWriteStateFileOfPackageError = 'Unable to write state '
|
||||
+'file "%s"%sof package %s.%sError: %s';
|
||||
lisPkgMangErrorReadingFile = 'Error reading file';
|
||||
lisCannotReadFile = 'Cannot read file %s';
|
||||
lisProjMangUnableToReadStateFileOfProjectError = 'Unable to read state '
|
||||
+'file %s of project %s%sError: %s';
|
||||
lisPkgMangUnableToReadStateFileOfPackageError = 'Unable to read state file '
|
||||
|
35
ide/main.pp
35
ide/main.pp
@ -4027,22 +4027,49 @@ procedure TMainIDE.mnuProjectResaveFormsWithI18n(Sender: TObject);
|
||||
var
|
||||
AnUnitInfo: TUnitInfo;
|
||||
LFMFileName: string;
|
||||
OpenStatus, WriteStatus: TModalResult;
|
||||
AbortFlag, ReadSaveFailFlag: boolean;
|
||||
begin
|
||||
AbortFlag:=false;
|
||||
AnUnitInfo:=Project1.FirstPartOfProject;
|
||||
while AnUnitInfo<>nil do
|
||||
while (AnUnitInfo<>nil) and (not AbortFlag) do
|
||||
begin
|
||||
ReadSaveFailFlag:=false;
|
||||
if FileNameIsPascalSource(AnUnitInfo.Filename) then
|
||||
begin
|
||||
LFMFileName:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename,true);
|
||||
if FileExistsCached(LFMFileName) and (not AnUnitInfo.DisableI18NForLFM) then
|
||||
if LazarusIDE.DoOpenEditorFile(AnUnitInfo.Filename,-1,-1,[ofAddToRecent])=mrOk then
|
||||
begin
|
||||
OpenStatus:=LazarusIDE.DoOpenEditorFile(AnUnitInfo.Filename,-1,-1,[ofAddToRecent]);
|
||||
if OpenStatus=mrOk then
|
||||
begin
|
||||
AnUnitInfo.Modified:=true;
|
||||
LazarusIDE.DoSaveEditorFile(AnUnitInfo.Filename,[]);
|
||||
WriteStatus:=LazarusIDE.DoSaveEditorFile(AnUnitInfo.Filename,[]);
|
||||
//DebugLn(['TMainIDE.mnuProjectResaveFormsWithI18n Resaving form "',AnUnitInfo.Filename,'"']);
|
||||
if WriteStatus<>mrOk then
|
||||
begin
|
||||
ReadSaveFailFlag:=true;
|
||||
if (WriteStatus=mrAbort) or
|
||||
(IDEMessageDialog(lisLazBuildErrorWritingFile, Format(
|
||||
lisCannotWriteFile, [AnUnitInfo.Filename]), mtError, [
|
||||
mbRetry, mbAbort])=mrAbort) then
|
||||
AbortFlag:=true;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
ReadSaveFailFlag:=true;
|
||||
if (OpenStatus=mrAbort) or
|
||||
(IDEMessageDialog(lisPkgMangErrorReadingFile, Format(
|
||||
lisCannotReadFile, [AnUnitInfo.Filename]), mtError, [mbRetry,
|
||||
mbAbort])=mrAbort) then
|
||||
AbortFlag:=true;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
AnUnitInfo:=AnUnitInfo.NextPartOfProject;
|
||||
//we try next file only if read and write were successful, otherwise we retry current file or abort
|
||||
if not ReadSaveFailFlag then
|
||||
AnUnitInfo:=AnUnitInfo.NextPartOfProject;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user