mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 11:39:55 +02:00
Converter: Remove invalid properties also after replacing a component type. Issue #24527
git-svn-id: trunk@41619 -
This commit is contained in:
parent
e06985f2bd
commit
01807a29cd
@ -490,8 +490,10 @@ begin
|
|||||||
if ClassUnitInfo<>nil then
|
if ClassUnitInfo<>nil then
|
||||||
NeededUnitName:=ClassUnitInfo.Unit_Name;
|
NeededUnitName:=ClassUnitInfo.Unit_Name;
|
||||||
end;
|
end;
|
||||||
if NeededUnitName<>'' then
|
if NeededUnitName<>'' then begin
|
||||||
fUsedUnitsTool.AddUnitIfNeeded(NeededUnitName);
|
fUsedUnitsTool.AddUnitImmediately(NeededUnitName);
|
||||||
|
Result:=mrRetry; // Caller must check LFM validity again
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -520,28 +522,29 @@ begin
|
|||||||
finally
|
finally
|
||||||
ConvTool.Free;
|
ConvTool.Free;
|
||||||
end;
|
end;
|
||||||
LoopCount:=0;
|
LoopCount:=0; // Prevent possible eternal loops with a counter
|
||||||
repeat
|
repeat
|
||||||
if not fLFMTree.ParseIfNeeded then exit;
|
repeat
|
||||||
|
if not fLFMTree.ParseIfNeeded then exit;
|
||||||
|
if CodeToolBoss.CheckLFM(fPascalBuffer, fLFMBuffer, fLFMTree,
|
||||||
|
fRootMustBeClassInUnit, fRootMustBeClassInIntf, fObjectsMustExist) then
|
||||||
|
Result:=mrOk
|
||||||
|
else // Rename/remove properties and types interactively.
|
||||||
|
Result:=ShowConvertLFMWizard; // Can return mrRetry.
|
||||||
|
Inc(LoopCount); // Increment counter in inner loop
|
||||||
|
until Result in [mrOK, mrCancel];
|
||||||
|
|
||||||
|
// Check for missing object types and add units as needed.
|
||||||
|
if not fLFMTree.ParseIfNeeded then
|
||||||
|
Exit(mrCancel);
|
||||||
if CodeToolBoss.CheckLFM(fPascalBuffer, fLFMBuffer, fLFMTree,
|
if CodeToolBoss.CheckLFM(fPascalBuffer, fLFMBuffer, fLFMTree,
|
||||||
fRootMustBeClassInUnit, fRootMustBeClassInIntf, fObjectsMustExist) then
|
fRootMustBeClassInUnit, fRootMustBeClassInIntf, fObjectsMustExist) then
|
||||||
Result:=mrOk
|
Result:=mrOk
|
||||||
else // Rename/remove properties and types interactively.
|
else begin
|
||||||
Result:=ShowConvertLFMWizard; // Can return mrRetry.
|
Result:=FindAndFixMissingComponentClasses; // Can return mrRetry.
|
||||||
Inc(LoopCount);
|
end;
|
||||||
until (Result in [mrOK, mrCancel]) or (LoopCount=20);
|
Inc(LoopCount); // Increment also in outer loop
|
||||||
|
until (Result in [mrOK, mrAbort]) or (LoopCount=30);
|
||||||
// Check for missing object types and add units as needed.
|
|
||||||
if not fLFMTree.ParseIfNeeded then
|
|
||||||
Exit(mrCancel);
|
|
||||||
if CodeToolBoss.CheckLFM(fPascalBuffer, fLFMBuffer, fLFMTree,
|
|
||||||
fRootMustBeClassInUnit, fRootMustBeClassInIntf, fObjectsMustExist) then
|
|
||||||
Result:=mrOk
|
|
||||||
else begin
|
|
||||||
Result:=FindAndFixMissingComponentClasses;
|
|
||||||
if Result = mrCancel then // Returns mrCancel when nothing was done.
|
|
||||||
Result := mrOK;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Fix top offsets of some components in visual containers
|
// Fix top offsets of some components in visual containers
|
||||||
if (Result=mrOK) and (fSettings.CoordOffsMode=rsEnabled) then begin
|
if (Result=mrOK) and (fSettings.CoordOffsMode=rsEnabled) then begin
|
||||||
|
@ -128,6 +128,7 @@ type
|
|||||||
function ConvertUsed: TModalResult;
|
function ConvertUsed: TModalResult;
|
||||||
function Remove(aUnit: string): TModalResult;
|
function Remove(aUnit: string): TModalResult;
|
||||||
procedure MoveMissingToComment(aAllCommentedUnits: TStrings);
|
procedure MoveMissingToComment(aAllCommentedUnits: TStrings);
|
||||||
|
function AddUnitImmediately(aUnitName: string): Boolean;
|
||||||
procedure AddUnitIfNeeded(aUnitName: string);
|
procedure AddUnitIfNeeded(aUnitName: string);
|
||||||
function AddThreadSupport: TModalResult;
|
function AddThreadSupport: TModalResult;
|
||||||
public
|
public
|
||||||
@ -689,6 +690,15 @@ begin
|
|||||||
fImplUsedUnits.fMissingUnits.Clear;
|
fImplUsedUnits.fMissingUnits.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TUsedUnitsTool.AddUnitImmediately(aUnitName: string): Boolean;
|
||||||
|
begin
|
||||||
|
with fCTLink, fMainUsedUnits do begin
|
||||||
|
Result:=CodeTool.AddUnitToSpecificUsesSection(fUsesSection, aUnitName, '', SrcCache);
|
||||||
|
if not Result then exit;
|
||||||
|
Result:=SrcCache.Apply;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TUsedUnitsTool.AddUnitIfNeeded(aUnitName: string);
|
procedure TUsedUnitsTool.AddUnitIfNeeded(aUnitName: string);
|
||||||
|
|
||||||
// Return True if the rename (target) value contains aUnitName.
|
// Return True if the rename (target) value contains aUnitName.
|
||||||
|
@ -396,12 +396,15 @@ begin
|
|||||||
if not CheckUnit then exit;
|
if not CheckUnit then exit;
|
||||||
if CodeToolBoss.CheckLFM(fPascalBuffer,fLFMBuffer,fLFMTree,
|
if CodeToolBoss.CheckLFM(fPascalBuffer,fLFMBuffer,fLFMTree,
|
||||||
fRootMustBeClassInUnit,fRootMustBeClassInIntf,fObjectsMustExist)
|
fRootMustBeClassInUnit,fRootMustBeClassInIntf,fObjectsMustExist)
|
||||||
then begin
|
then
|
||||||
Result:=mrOk;
|
exit(mrOk);
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
Result:=FindAndFixMissingComponentClasses;
|
Result:=FindAndFixMissingComponentClasses;
|
||||||
if Result in [mrAbort,mrOk] then exit;
|
if Result=mrAbort then exit;
|
||||||
|
// check LFM again
|
||||||
|
if CodeToolBoss.CheckLFM(fPascalBuffer,fLFMBuffer,fLFMTree,
|
||||||
|
fRootMustBeClassInUnit,fRootMustBeClassInIntf,fObjectsMustExist)
|
||||||
|
then
|
||||||
|
exit(mrOk);
|
||||||
WriteLFMErrors;
|
WriteLFMErrors;
|
||||||
Result:=ShowRepairLFMWizard;
|
Result:=ShowRepairLFMWizard;
|
||||||
end;
|
end;
|
||||||
@ -463,7 +466,7 @@ var
|
|||||||
RegComp: TRegisteredComponent;
|
RegComp: TRegisteredComponent;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrOK;
|
||||||
MissingObjectTypes:=TStringList.Create;
|
MissingObjectTypes:=TStringList.Create;
|
||||||
try
|
try
|
||||||
// collect all missing object types
|
// collect all missing object types
|
||||||
@ -496,15 +499,6 @@ begin
|
|||||||
// add units for the missing object types with registered component classes
|
// add units for the missing object types with registered component classes
|
||||||
Result:=PackageEditingInterface.AddUnitDependenciesForComponentClasses(
|
Result:=PackageEditingInterface.AddUnitDependenciesForComponentClasses(
|
||||||
fPascalBuffer.Filename, aMissingTypes);
|
fPascalBuffer.Filename, aMissingTypes);
|
||||||
if Result<>mrOk then exit;
|
|
||||||
// check LFM again
|
|
||||||
if CodeToolBoss.CheckLFM(fPascalBuffer,fLFMBuffer,fLFMTree,
|
|
||||||
fRootMustBeClassInUnit,fRootMustBeClassInIntf,fObjectsMustExist)
|
|
||||||
then begin
|
|
||||||
Result:=mrOk;
|
|
||||||
end else begin
|
|
||||||
Result:=mrCancel;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLFMChecker.CheckUnit: boolean;
|
function TLFMChecker.CheckUnit: boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user