mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 19:39:30 +02:00
Converter: there was an extra cycle with LFM replace loop. Fixed.
git-svn-id: trunk@26127 -
This commit is contained in:
parent
47e48c80c5
commit
e15d883f82
@ -68,8 +68,8 @@ type
|
||||
TLFMFixer = class(TLFMChecker)
|
||||
private
|
||||
fSettings: TConvertSettings;
|
||||
// There are also unknown object types, not just properties.
|
||||
fHasMissingObjectTypes: Boolean;
|
||||
fHasMissingProperties: Boolean; // LFM file has unknown properties.
|
||||
fHasMissingObjectTypes: Boolean; // LFM file has unknown object types.
|
||||
// References to controls in UI:
|
||||
fPropReplaceGrid: TStringGrid;
|
||||
fTypeReplaceGrid: TStringGrid;
|
||||
@ -236,6 +236,7 @@ constructor TLFMFixer.Create(APascalBuffer, ALFMBuffer: TCodeBuffer;
|
||||
const AOnOutput: TOnAddFilteredLine);
|
||||
begin
|
||||
inherited Create(APascalBuffer, ALFMBuffer, AOnOutput);
|
||||
fHasMissingProperties:=false;
|
||||
fHasMissingObjectTypes:=false;
|
||||
end;
|
||||
|
||||
@ -322,8 +323,9 @@ var
|
||||
PropUpdater: TGridUpdater;
|
||||
TypeUpdater: TGridUpdater;
|
||||
CurError: TLFMError;
|
||||
OldIdent: string;
|
||||
OldIdent, NewIdent: string;
|
||||
begin
|
||||
fHasMissingProperties:=false;
|
||||
fHasMissingObjectTypes:=false;
|
||||
// ReplaceTypes is used for properties just in case it will provide some.
|
||||
PropUpdater:=TGridUpdater.Create(fSettings.ReplaceTypes, fPropReplaceGrid);
|
||||
@ -334,12 +336,14 @@ begin
|
||||
while CurError<>nil do begin
|
||||
if CurError.IsMissingObjectType then begin
|
||||
OldIdent:=(CurError.Node as TLFMObjectNode).TypeName;
|
||||
TypeUpdater.AddUnique(OldIdent); // Add a unique type only once.
|
||||
NewIdent:=TypeUpdater.AddUnique(OldIdent); // Add each type only once.
|
||||
if NewIdent<>'' then
|
||||
fHasMissingObjectTypes:=true;
|
||||
end
|
||||
else begin
|
||||
OldIdent:=CurError.Node.GetIdentifier;
|
||||
PropUpdater.AddUnique(OldIdent); // Add a unique property only once.
|
||||
PropUpdater.AddUnique(OldIdent); // Add each property only once.
|
||||
fHasMissingProperties:=true;
|
||||
end;
|
||||
CurError:=CurError.NextError;
|
||||
end;
|
||||
@ -369,7 +373,8 @@ begin
|
||||
fPropReplaceGrid:=FixLFMDialog.PropReplaceGrid;
|
||||
fTypeReplaceGrid:=FixLFMDialog.TypeReplaceGrid;
|
||||
LoadLFM;
|
||||
if fSettings.AutoRemoveProperties and not fHasMissingObjectTypes then
|
||||
if (fSettings.AutoRemoveProperties or not fHasMissingProperties)
|
||||
and not fHasMissingObjectTypes then
|
||||
Result:=ReplaceAndRemoveAll
|
||||
else begin
|
||||
// Cursor is earlier set to HourGlass. Show normal cursor while in dialog.
|
||||
|
@ -33,7 +33,7 @@ type
|
||||
public
|
||||
constructor Create(AStringsMap: TStringToStringTree; AGrid: TStringGrid);
|
||||
destructor Destroy; override;
|
||||
procedure AddUnique(AOldIdent: string);
|
||||
function AddUnique(AOldIdent: string): string;
|
||||
end;
|
||||
|
||||
{ TReplaceNamesForm }
|
||||
@ -201,19 +201,18 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TGridUpdater.AddUnique(AOldIdent: string);
|
||||
function TGridUpdater.AddUnique(AOldIdent: string): string;
|
||||
// Add a new Delphi -> Lazarus mapping to the grid.
|
||||
var
|
||||
NewIdent: string;
|
||||
// Returns the replacement string.
|
||||
begin
|
||||
// Add only one instance of each property name.
|
||||
if fSeenNames.IndexOf(AOldIdent)<0 then begin
|
||||
// Add only one instance of each name.
|
||||
fSeenNames.Append(AOldIdent);
|
||||
FindReplacement(AOldIdent, NewIdent);
|
||||
FindReplacement(AOldIdent, Result);
|
||||
if fGrid.RowCount<GridEndInd+1 then
|
||||
fGrid.RowCount:=GridEndInd+1;
|
||||
fGrid.Cells[0,GridEndInd]:=AOldIdent;
|
||||
fGrid.Cells[1,GridEndInd]:=NewIdent;
|
||||
fGrid.Cells[1,GridEndInd]:=Result;
|
||||
Inc(GridEndInd);
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user