IDE: fixed checking circle dependencies between designer properties

git-svn-id: trunk@14880 -
This commit is contained in:
mattias 2008-04-18 18:20:06 +00:00
parent 6a8f9555e3
commit 3f1466b361
4 changed files with 74 additions and 41 deletions

View File

@ -6045,8 +6045,9 @@ begin
{$ENDIF}
OldDesigner.FreeDesigner(true);
AnUnitInfo.Component:=nil;
FreeUnusedComponents;
end;
Project1.InvalidateUnitComponentDesignerDependencies;
FreeUnusedComponents;
end;
finally
Project1.UnlockUnitComponentDependencies;

View File

@ -523,7 +523,8 @@ type
TLazProjectStateFlag = (
lpsfStateFileLoaded,
lpsfUnitCompDependenciesNeedUpdate
lpsfPropertyDependenciesChanged,
lpsfDesignerChanged
);
TLazProjectStateFlags = set of TLazProjectStateFlag;
@ -744,6 +745,7 @@ type
procedure LockUnitComponentDependencies;
procedure UnlockUnitComponentDependencies;
procedure UpdateUnitComponentDependencies;
procedure InvalidateUnitComponentDesignerDependencies;
procedure ClearUnitComponentDependencies(
ClearTypes: TUnitCompDependencyTypes);
@ -3465,7 +3467,8 @@ begin
inc(FLockUnitComponentDependencies);
if FLockUnitComponentDependencies=1 then begin
// update once
Include(FStateFlags,lpsfUnitCompDependenciesNeedUpdate);
Include(FStateFlags,lpsfPropertyDependenciesChanged);
Include(FStateFlags,lpsfDesignerChanged);
end;
end;
@ -3518,7 +3521,9 @@ procedure TProject.UpdateUnitComponentDependencies;
ReferenceUnit:=UnitWithComponent(OwnerComponent);
if ReferenceUnit<>nil then begin
// property references another unit
{$IFDEF VerboseIDEMultiForm}
DebugLn(['TProject.UpdateUnitComponentDependencies multi form reference found: ',AnUnitInfo.Filename,' -> ',ReferenceUnit.Filename]);
{$ENDIF}
AnUnitInfo.AddRequiresComponentDependency(
ReferenceUnit,[ucdtProperty]);
end;
@ -3532,7 +3537,7 @@ procedure TProject.UpdateUnitComponentDependencies;
until TypeInfo=nil;
end;
procedure DFSUsedByDesigner(AnUnitInfo: TUnitInfo);
procedure DFSUsedByDesigner(AnUnitInfo, IgnoreUnitInfo: TUnitInfo);
var
Dependency: TUnitComponentDependency;
UsedByUnitInfo: TUnitInfo;
@ -3544,10 +3549,14 @@ procedure TProject.UpdateUnitComponentDependencies;
Dependency:=AnUnitInfo.FirstUsedByComponent;
while Dependency<>nil do begin
UsedByUnitInfo:=Dependency.UsedByUnit;
if not (uifComponentIndirectlyUsedByDesigner in UsedByUnitInfo.FFlags)
if (UsedByUnitInfo<>IgnoreUnitInfo)
and (not (uifComponentIndirectlyUsedByDesigner in UsedByUnitInfo.FFlags))
then begin
{$IFDEF VerboseIDEMultiForm}
DebugLn(['DFSUsedByDesigner used indirect by designer: ',UsedByUnitInfo.Filename]);
{$ENDIF}
Include(UsedByUnitInfo.FFlags,uifComponentIndirectlyUsedByDesigner);
DFSUsedByDesigner(UsedByUnitInfo);
DFSUsedByDesigner(UsedByUnitInfo,IgnoreUnitInfo);
end;
Dependency:=Dependency.NextUsedByDependency;
end;
@ -3557,42 +3566,63 @@ var
AnUnitInfo: TUnitInfo;
i: Integer;
begin
if (FLockUnitComponentDependencies>0)
and (not (lpsfUnitCompDependenciesNeedUpdate in FStateFlags)) then begin
// the dependencies are locked and up2date
exit;
if (FLockUnitComponentDependencies=0)
or (lpsfPropertyDependenciesChanged in FStateFlags) then begin
Exclude(FStateFlags,lpsfPropertyDependenciesChanged);
// clear dependencies
ClearUnitComponentDependencies([ucdtProperty]);
{$IFDEF VerboseIDEMultiForm}
DebugLn(['TProject.UpdateUnitComponentDependencies checking properties ...']);
{$ENDIF}
// find property dependencies
AnUnitInfo:=FirstUnitWithComponent;
while AnUnitInfo<>nil do begin
Search(AnUnitInfo,AnUnitInfo.Component);
for i:=AnUnitInfo.Component.ComponentCount-1 downto 0 do
Search(AnUnitInfo,AnUnitInfo.Component.Components[i]);
AnUnitInfo:=AnUnitInfo.NextUnitWithComponent;
end;
end;
Exclude(FStateFlags,lpsfUnitCompDependenciesNeedUpdate);
// clear dependencies
ClearUnitComponentDependencies([ucdtProperty]);
DebugLn(['TProject.UpdateUnitComponentDependencies ']);
// find simple dependencies (unit to unit and unit to designer)
AnUnitInfo:=FirstUnitWithComponent;
while AnUnitInfo<>nil do begin
// search unit to unit dependencies
Search(AnUnitInfo,AnUnitInfo.Component);
for i:=AnUnitInfo.Component.ComponentCount-1 downto 0 do
Search(AnUnitInfo,AnUnitInfo.Component.Components[i]);
// search designer dependencies
Exclude(AnUnitInfo.FFlags,uifMarked);
Exclude(AnUnitInfo.FFlags,uifComponentIndirectlyUsedByDesigner);
if FindRootDesigner(AnUnitInfo.Component)<>nil then
Include(AnUnitInfo.FFlags,uifComponentUsedByDesigner)
else
Exclude(AnUnitInfo.FFlags,uifComponentUsedByDesigner);
// next
AnUnitInfo:=AnUnitInfo.NextUnitWithComponent;
end;
// mark all units that are used indirectly by a designer
AnUnitInfo:=FirstUnitWithComponent;
while AnUnitInfo<>nil do begin
if (uifComponentUsedByDesigner in AnUnitInfo.FFlags)
and (not (uifComponentIndirectlyUsedByDesigner in AnUnitInfo.FFlags)) then
DFSUsedByDesigner(AnUnitInfo);
AnUnitInfo:=AnUnitInfo.NextUnitWithComponent;
if (FLockUnitComponentDependencies=0)
or (lpsfDesignerChanged in FStateFlags) then begin
Exclude(FStateFlags,lpsfDesignerChanged);
{$IFDEF VerboseIDEMultiForm}
DebugLn(['TProject.UpdateUnitComponentDependencies checking designers ...']);
{$ENDIF}
// find designer dependencies
AnUnitInfo:=FirstUnitWithComponent;
while AnUnitInfo<>nil do begin
Exclude(AnUnitInfo.FFlags,uifMarked);
Exclude(AnUnitInfo.FFlags,uifComponentIndirectlyUsedByDesigner);
if FindRootDesigner(AnUnitInfo.Component)<>nil then begin
{$IFDEF VerboseIDEMultiForm}
DebugLn(['TProject.UpdateUnitComponentDependencies used by designer: ',AnUnitInfo.Filename]);
{$ENDIF}
Include(AnUnitInfo.FFlags,uifComponentUsedByDesigner);
end else
Exclude(AnUnitInfo.FFlags,uifComponentUsedByDesigner);
AnUnitInfo:=AnUnitInfo.NextUnitWithComponent;
end;
// mark all units that are used indirectly by a designer
AnUnitInfo:=FirstUnitWithComponent;
while AnUnitInfo<>nil do begin
if (uifComponentUsedByDesigner in AnUnitInfo.FFlags) then
begin
// mark all that use indirectly this designer
Exclude(AnUnitInfo.FFlags,uifMarked);
DFSUsedByDesigner(AnUnitInfo,AnUnitInfo);
end;
AnUnitInfo:=AnUnitInfo.NextUnitWithComponent;
end;
end;
end;
procedure TProject.InvalidateUnitComponentDesignerDependencies;
begin
Include(FStateFlags,lpsfDesignerChanged);
end;
procedure TProject.ClearUnitComponentDependencies(
ClearTypes: TUnitCompDependencyTypes);
var

View File

@ -1,4 +1,4 @@
{%MainUnit gtk2int.pp}
{%MainUnit gtk2int.pas}
{ $Id$ }
{******************************************************************************
All GTK2 Winapi implementations.
@ -518,8 +518,10 @@ begin
GtkWindow:=PGtkWindow(hWnd);
if GtkWindow=nil then
RaiseGDBException('TGtk2WidgetSet.ShowWindow hWnd is nil');
if not GtkWidgetIsA(PGtkWidget(GtkWindow),GTK_TYPE_WINDOW) then
if not GtkWidgetIsA(PGtkWidget(GtkWindow),GTK_TYPE_WINDOW) then begin
DebugLn(['TGtk2WidgetSet.ShowWindow ',GetWidgetDebugReport(PGTKWidget(GtkWindow))]);
RaiseGDBException('TGtk2WidgetSet.ShowWindow hWnd is not a gtkwindow');
end;
//debugln('TGtk2WidgetSet.ShowWindow A ',GetWidgetDebugReport(PGtkWidget(GtkWindow)),' nCmdShow=',dbgs(nCmdShow),' SW_MINIMIZE=',dbgs(SW_MINIMIZE=nCmdShow));

View File

@ -1,4 +1,4 @@
{%MainUnit gtk2int.pp}
{%MainUnit gtk2int.pas}
{ $Id$ }
// included by gtk2int.pp