From 1cc1c541af1130544e15c5af6c2817445958db09 Mon Sep 17 00:00:00 2001 From: juha Date: Tue, 2 Jul 2013 12:57:31 +0000 Subject: [PATCH] Converter: do dummy string replacement for known problematic syntax when CodeTools raised an exception. Issue #23552 git-svn-id: trunk@41967 - --- converter/convertdelphi.pas | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/converter/convertdelphi.pas b/converter/convertdelphi.pas index 2494251f28..4c85faf0e4 100644 --- a/converter/convertdelphi.pas +++ b/converter/convertdelphi.pas @@ -504,6 +504,8 @@ begin end; function TDelphiUnit.CopyAndLoadFile: TModalResult; +var + CodeOk, CodeFixed: Boolean; begin fOwnerConverter.fSettings.AddLogLine(Format(lisConvDelphiConvertingFile, [fOrigUnitFilename])); @@ -536,8 +538,25 @@ begin // Fix include file names. Result:=FixIncludeFiles; if Result<>mrOK then exit; - // Create a tool for missing units. - fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename); + CodeFixed:=False; + repeat + CodeOk:=True; + try + // Create a tool for missing units. + fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename); + except + // If CodeTool's BuildTree raised exception, try dummy replacement for + // some known problematic syntax, currently only OleVariant.type. + if CodeFixed then + Raise // There was a second exception -> we are doomed! + else begin + with fPascalBuffer do + Source:=StringReplace(Source,'.type','.&type',[rfReplaceAll]); + CodeOk := False; + CodeFixed := True; // Try replacements only once + end; + end; + until CodeOk; if fOwnerConverter is TConvertDelphiProjPack then with TConvertDelphiProjPack(fOwnerConverter) do begin fUsedUnitsTool.OnCheckPackageDependency:=@CheckPackageDep;