mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-27 21:29:54 +02:00
IDE: implemented closing designer without freeing component
git-svn-id: trunk@10010 -
This commit is contained in:
parent
84d62b1b15
commit
099ee4dc99
@ -217,7 +217,7 @@ type
|
|||||||
|
|
||||||
constructor Create(TheDesignerForm: TCustomForm;
|
constructor Create(TheDesignerForm: TCustomForm;
|
||||||
AControlSelection: TControlSelection);
|
AControlSelection: TControlSelection);
|
||||||
procedure DeleteFormAndFree;
|
procedure FreeDesigner(FreeComponent: boolean);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
procedure Modified; override;
|
procedure Modified; override;
|
||||||
@ -466,7 +466,7 @@ begin
|
|||||||
IgnoreDeletingPersistent:=TList.Create;
|
IgnoreDeletingPersistent:=TList.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesigner.DeleteFormAndFree;
|
procedure TDesigner.FreeDesigner(FreeComponent: boolean);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
@ -478,12 +478,14 @@ begin
|
|||||||
TheControlSelection.Remove(LookupRoot);
|
TheControlSelection.Remove(LookupRoot);
|
||||||
if GlobalDesignHook.LookupRoot=FLookupRoot then
|
if GlobalDesignHook.LookupRoot=FLookupRoot then
|
||||||
GlobalDesignHook.LookupRoot:=nil;
|
GlobalDesignHook.LookupRoot:=nil;
|
||||||
// tell hooks about deleting
|
if FreeComponent then begin
|
||||||
for i:=FLookupRoot.ComponentCount-1 downto 0 do
|
// tell hooks about deleting
|
||||||
GlobalDesignHook.PersistentDeleting(FLookupRoot.Components[i]);
|
for i:=FLookupRoot.ComponentCount-1 downto 0 do
|
||||||
GlobalDesignHook.PersistentDeleting(FLookupRoot);
|
GlobalDesignHook.PersistentDeleting(FLookupRoot.Components[i]);
|
||||||
|
GlobalDesignHook.PersistentDeleting(FLookupRoot);
|
||||||
|
end;
|
||||||
// delete
|
// delete
|
||||||
TheFormEditor.DeleteComponent(FLookupRoot,true);
|
TheFormEditor.DeleteComponent(FLookupRoot,FreeComponent);
|
||||||
end;
|
end;
|
||||||
Free;
|
Free;
|
||||||
end;
|
end;
|
||||||
|
@ -287,6 +287,9 @@ function CompareComponentAndInterface(Key, Data: Pointer): integer;
|
|||||||
function CompareDefPropCacheItems(Item1, Item2: TDefinePropertiesCacheItem): integer;
|
function CompareDefPropCacheItems(Item1, Item2: TDefinePropertiesCacheItem): integer;
|
||||||
function ComparePersClassNameAndDefPropCacheItem(Key: Pointer;
|
function ComparePersClassNameAndDefPropCacheItem(Key: Pointer;
|
||||||
Item: TDefinePropertiesCacheItem): integer;
|
Item: TDefinePropertiesCacheItem): integer;
|
||||||
|
|
||||||
|
function TryFreeComponent(var AComponent: TComponent): boolean;
|
||||||
|
|
||||||
procedure RegisterStandardClasses;
|
procedure RegisterStandardClasses;
|
||||||
|
|
||||||
|
|
||||||
@ -330,6 +333,35 @@ begin
|
|||||||
RegisterClasses([TStringList]);
|
RegisterClasses([TStringList]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TryFreeComponent(var AComponent: TComponent): boolean;
|
||||||
|
var
|
||||||
|
OldName, OldClassName: string;
|
||||||
|
Begin
|
||||||
|
Result:=false;
|
||||||
|
{$IFNDEF NoCompCatch}
|
||||||
|
try
|
||||||
|
{$ENDIF}
|
||||||
|
OldName:=AComponent.Name;
|
||||||
|
OldClassName:=AComponent.ClassName;
|
||||||
|
AComponent.Free;
|
||||||
|
Result := True;
|
||||||
|
{$IFNDEF NoCompCatch}
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
DebugLn('TComponentInterface.Delete ERROR:',
|
||||||
|
' "'+OldName+':'+OldClassName+'" ',E.Message);
|
||||||
|
DumpExceptionBackTrace;
|
||||||
|
MessageDlg('Error',
|
||||||
|
'An exception occured during deletion of'#13
|
||||||
|
+'"'+OldName+':'+OldClassName+'"'#13
|
||||||
|
+E.Message,
|
||||||
|
mtError,[mbOk],0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
AComponent:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TComponentInterface }
|
{ TComponentInterface }
|
||||||
|
|
||||||
constructor TComponentInterface.Create;
|
constructor TComponentInterface.Create;
|
||||||
@ -708,8 +740,8 @@ Begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TComponentInterface.Focus : Boolean;
|
function TComponentInterface.Focus : Boolean;
|
||||||
Begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
if (FComponent is TWinControl) and (TWinControl(FComponent).CanFocus) then
|
if (FComponent is TWinControl) and (TWinControl(FComponent).CanFocus) then
|
||||||
Begin
|
Begin
|
||||||
@ -718,39 +750,16 @@ Begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TComponentInterface.Delete: Boolean;
|
function TComponentInterface.Delete: Boolean;
|
||||||
var
|
begin
|
||||||
OldName, OldClassName: string;
|
|
||||||
Begin
|
|
||||||
{$IFDEF VerboseFormEditor}
|
{$IFDEF VerboseFormEditor}
|
||||||
writeln('TComponentInterface.Delete A ',Component.Name,':',Component.ClassName);
|
writeln('TComponentInterface.Delete A ',Component.Name,':',Component.ClassName);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFNDEF NoCompCatch}
|
Result:=TryFreeComponent(component);
|
||||||
try
|
|
||||||
{$ENDIF}
|
|
||||||
OldName:=Component.Name;
|
|
||||||
OldClassName:=Component.ClassName;
|
|
||||||
Component.Free;
|
|
||||||
{$IFNDEF NoCompCatch}
|
|
||||||
except
|
|
||||||
on E: Exception do begin
|
|
||||||
DebugLn('TComponentInterface.Delete ERROR:',
|
|
||||||
' "'+OldName+':'+OldClassName+'" ',E.Message);
|
|
||||||
DumpExceptionBackTrace;
|
|
||||||
MessageDlg('Error',
|
|
||||||
'An exception occured during deletion of'#13
|
|
||||||
+'"'+OldName+':'+OldClassName+'"'#13
|
|
||||||
+E.Message,
|
|
||||||
mtError,[mbOk],0);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
|
||||||
FComponent:=nil;
|
|
||||||
{$IFDEF VerboseFormEditor}
|
{$IFDEF VerboseFormEditor}
|
||||||
writeln('TComponentInterface.Delete B ');
|
writeln('TComponentInterface.Delete B ');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Free;
|
Free;
|
||||||
Result := True;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TComponentInterface.GetComponentEditor: TBaseComponentEditor;
|
function TComponentInterface.GetComponentEditor: TBaseComponentEditor;
|
||||||
@ -820,56 +829,55 @@ end;
|
|||||||
Procedure TCustomFormEditor.DeleteComponent(AComponent: TComponent;
|
Procedure TCustomFormEditor.DeleteComponent(AComponent: TComponent;
|
||||||
FreeComponent: boolean);
|
FreeComponent: boolean);
|
||||||
var
|
var
|
||||||
Temp : TComponentInterface;
|
CompIntf : TComponentInterface;
|
||||||
i: integer;
|
i: integer;
|
||||||
AForm: TCustomForm;
|
AForm: TCustomForm;
|
||||||
Begin
|
Begin
|
||||||
Temp := TComponentInterface(FindComponent(AComponent));
|
CompIntf := TComponentInterface(FindComponent(AComponent));
|
||||||
if Temp <> nil then
|
if CompIntf <> nil then
|
||||||
begin
|
FComponentInterfaces.Remove(CompIntf);
|
||||||
FComponentInterfaces.Remove(Temp);
|
|
||||||
|
|
||||||
DebugLn('TCustomFormEditor.DeleteControl ',
|
DebugLn(['TCustomFormEditor.DeleteControl ',DbgSName(AComponent),' IsJITComponent=',IsJITComponent(AComponent)]);
|
||||||
AComponent.ClassName,' ',BoolToStr(IsJITComponent(AComponent)));
|
if IsJITComponent(AComponent) then begin
|
||||||
if IsJITComponent(AComponent) then begin
|
// value is a top level component
|
||||||
// value is a top level component
|
i:=AComponent.ComponentCount-1;
|
||||||
if FreeComponent then begin
|
while i>=0 do begin
|
||||||
|
DeleteComponent(AComponent.Components[i],FreeComponent);
|
||||||
|
dec(i);
|
||||||
|
if i>AComponent.ComponentCount-1 then
|
||||||
i:=AComponent.ComponentCount-1;
|
i:=AComponent.ComponentCount-1;
|
||||||
while i>=0 do begin
|
|
||||||
DeleteComponent(AComponent.Components[i],true);
|
|
||||||
dec(i);
|
|
||||||
if i>AComponent.ComponentCount-1 then
|
|
||||||
i:=AComponent.ComponentCount-1;
|
|
||||||
end;
|
|
||||||
if PropertyEditorHook.LookupRoot=AComponent then
|
|
||||||
PropertyEditorHook.LookupRoot:=nil;
|
|
||||||
if JITFormList.IsJITForm(AComponent) then
|
|
||||||
// free a form component
|
|
||||||
JITFormList.DestroyJITComponent(AComponent)
|
|
||||||
else if JITNonFormList.IsJITNonForm(AComponent) then begin
|
|
||||||
// free a non form component and its designer form
|
|
||||||
AForm:=GetDesignerForm(AComponent);
|
|
||||||
if not (AForm is TNonControlDesignerForm) then
|
|
||||||
RaiseException('TCustomFormEditor.DeleteControl Where is the TNonControlDesignerForm? '+AComponent.ClassName);
|
|
||||||
FNonControlForms.Remove(AForm);
|
|
||||||
TNonControlDesignerForm(AForm).LookupRoot:=nil;
|
|
||||||
AForm.Free;
|
|
||||||
JITNonFormList.DestroyJITComponent(AComponent);
|
|
||||||
end else
|
|
||||||
RaiseException('TCustomFormEditor.DeleteControl '+AComponent.ClassName);
|
|
||||||
end;
|
|
||||||
Temp.Free;
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
// value is a normal child component
|
|
||||||
if FreeComponent then
|
|
||||||
Temp.Delete
|
|
||||||
else
|
|
||||||
Temp.Free;
|
|
||||||
end;
|
end;
|
||||||
end else begin
|
if PropertyEditorHook.LookupRoot=AComponent then
|
||||||
|
PropertyEditorHook.LookupRoot:=nil;
|
||||||
|
if JITFormList.IsJITForm(AComponent) then begin
|
||||||
|
// free/unbind a form component
|
||||||
|
if FreeComponent then
|
||||||
|
JITFormList.DestroyJITComponent(AComponent);
|
||||||
|
end else if JITNonFormList.IsJITNonForm(AComponent) then begin
|
||||||
|
// free/unbind a non form component and its designer form
|
||||||
|
AForm:=GetDesignerForm(AComponent);
|
||||||
|
if (AForm<>nil) and (not (AForm is TNonControlDesignerForm)) then
|
||||||
|
RaiseException('TCustomFormEditor.DeleteControl Where is the TNonControlDesignerForm? '+AComponent.ClassName);
|
||||||
|
if AForm<>nil then begin
|
||||||
|
FNonControlForms.Remove(AForm);
|
||||||
|
TNonControlDesignerForm(AForm).LookupRoot:=nil;
|
||||||
|
TryFreeComponent(AForm);
|
||||||
|
end;
|
||||||
|
if FreeComponent then
|
||||||
|
JITNonFormList.DestroyJITComponent(AComponent);
|
||||||
|
end else
|
||||||
|
RaiseException('TCustomFormEditor.DeleteControl '+AComponent.ClassName);
|
||||||
|
CompIntf.Free;
|
||||||
|
end
|
||||||
|
else if CompIntf<>nil then begin
|
||||||
|
// value is a normal child component
|
||||||
if FreeComponent then
|
if FreeComponent then
|
||||||
AComponent.Free;
|
CompIntf.Delete
|
||||||
|
else
|
||||||
|
CompIntf.Free;
|
||||||
|
end else if FreeComponent then begin
|
||||||
|
DebugLn(['WARNING: TCustomFormEditor.DeleteComponent freeing orphaned component ',DbgSName(AComponent)]);
|
||||||
|
TryFreeComponent(AComponent);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
96
ide/main.pp
96
ide/main.pp
@ -584,7 +584,9 @@ type
|
|||||||
var ComponentUnitInfo: TUnitInfo): TModalResult;
|
var ComponentUnitInfo: TUnitInfo): TModalResult;
|
||||||
|
|
||||||
// methods for 'close unit'
|
// methods for 'close unit'
|
||||||
function CloseDesignerForm(AnUnitInfo: TUnitInfo): TModalResult;
|
function CloseUnitComponent(AnUnitInfo: TUnitInfo): TModalResult;
|
||||||
|
function UnitComponentIsUsed(AnUnitInfo: TUnitInfo;
|
||||||
|
CheckHasDesigner: boolean): boolean;
|
||||||
|
|
||||||
// methods for creating a project
|
// methods for creating a project
|
||||||
function CreateProjectObject(ProjectDesc,
|
function CreateProjectObject(ProjectDesc,
|
||||||
@ -4754,7 +4756,7 @@ var
|
|||||||
LFMFilename: string;
|
LFMFilename: string;
|
||||||
LFMBuf: TCodeBuffer;
|
LFMBuf: TCodeBuffer;
|
||||||
begin
|
begin
|
||||||
CloseDesignerForm(AnUnitInfo);
|
CloseUnitComponent(AnUnitInfo);
|
||||||
|
|
||||||
// Note: think about virtual and normal .lfm files.
|
// Note: think about virtual and normal .lfm files.
|
||||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
||||||
@ -4801,7 +4803,7 @@ begin
|
|||||||
|
|
||||||
// close old designer form
|
// close old designer form
|
||||||
if CloseDsgnForm then
|
if CloseDsgnForm then
|
||||||
CloseDesignerForm(AnUnitInfo)
|
CloseUnitComponent(AnUnitInfo)
|
||||||
else if AnUnitInfo.Component<>nil then begin
|
else if AnUnitInfo.Component<>nil then begin
|
||||||
DebugLn(['TMainIDE.DoLoadLFM INCONSISTENCY CloseDsgnForm=',CloseDsgnForm,' Filename=',AnUnitInfo.Filename,' Component=',dbgsName(AnUnitInfo.Component)]);
|
DebugLn(['TMainIDE.DoLoadLFM INCONSISTENCY CloseDsgnForm=',CloseDsgnForm,' Filename=',AnUnitInfo.Filename,' Component=',dbgsName(AnUnitInfo.Component)]);
|
||||||
exit(mrAbort);
|
exit(mrAbort);
|
||||||
@ -5113,17 +5115,31 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
function TMainIDE.CloseDesignerForm
|
function TMainIDE.CloseUnitComponent
|
||||||
|
|
||||||
Params: AnUnitInfo: TUnitInfo
|
Params: AnUnitInfo: TUnitInfo
|
||||||
Result: TModalResult;
|
Result: TModalResult;
|
||||||
|
|
||||||
Free the designer form of a unit.
|
Free the designer form of a unit.
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
function TMainIDE.CloseDesignerForm(AnUnitInfo: TUnitInfo): TModalResult;
|
function TMainIDE.CloseUnitComponent(AnUnitInfo: TUnitInfo): TModalResult;
|
||||||
|
|
||||||
|
procedure FreeUnusedComponents;
|
||||||
|
var
|
||||||
|
CompUnitInfo: TUnitInfo;
|
||||||
|
begin
|
||||||
|
CompUnitInfo:=Project1.FirstUnitWithComponent;
|
||||||
|
while CompUnitInfo<>nil do begin
|
||||||
|
if not UnitComponentIsUsed(CompUnitInfo,true) then begin
|
||||||
|
CloseUnitComponent(CompUnitInfo);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
CompUnitInfo:=CompUnitInfo.NextUnitWithComponent;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
AForm: TCustomForm;
|
AForm: TCustomForm;
|
||||||
i: integer;
|
|
||||||
OldDesigner: TDesigner;
|
OldDesigner: TDesigner;
|
||||||
LookupRoot: TComponent;
|
LookupRoot: TComponent;
|
||||||
begin
|
begin
|
||||||
@ -5134,25 +5150,57 @@ begin
|
|||||||
OldDesigner:=nil;
|
OldDesigner:=nil;
|
||||||
if AForm<>nil then
|
if AForm<>nil then
|
||||||
OldDesigner:=TDesigner(AForm.Designer);
|
OldDesigner:=TDesigner(AForm.Designer);
|
||||||
|
if FLastFormActivated=AForm then
|
||||||
|
FLastFormActivated:=nil;
|
||||||
if (OldDesigner=nil) then begin
|
if (OldDesigner=nil) then begin
|
||||||
DebugLn(['TMainIDE.CloseDesignerForm TODO: free hidden component without designer: ',AnUnitInfo.Filename,' ',DbgSName(AnUnitInfo.Component)]);
|
// hidden component
|
||||||
|
DebugLn(['TMainIDE.CloseUnitComponent freeing hidden component without designer: ',AnUnitInfo.Filename,' ',DbgSName(AnUnitInfo.Component)]);
|
||||||
|
if UnitComponentIsUsed(AnUnitInfo,false) then begin
|
||||||
|
// hidden component is still used => keep it
|
||||||
|
end else begin
|
||||||
|
// hidden component is not used => free it
|
||||||
|
FormEditor1.DeleteComponent(LookupRoot,true);
|
||||||
|
AnUnitInfo.Component:=nil;
|
||||||
|
FreeUnusedComponents;
|
||||||
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
if (AForm=nil) then exit;
|
// component with designer
|
||||||
if FLastFormActivated=AForm then
|
if UnitComponentIsUsed(AnUnitInfo,false) then begin
|
||||||
FLastFormActivated:=nil;
|
// free designer, keep component hidden
|
||||||
//debugln('TMainIDE.CloseDesignerForm A ',AnUnitInfo.Filename,' ',dbgsName(LookupRoot));
|
DebugLn(['TMainIDE.CloseUnitComponent hiding component and freeing designer: ',AnUnitInfo.Filename,' ',DbgSName(AnUnitInfo.Component)]);
|
||||||
|
LCLIntf.ShowWindow(AForm.Handle,SW_HIDE);
|
||||||
// unselect components
|
OldDesigner.FreeDesigner(false);
|
||||||
for i:=LookupRoot.ComponentCount-1 downto 0 do
|
end else begin
|
||||||
TheControlSelection.Remove(LookupRoot.Components[i]);
|
// free designer and design form
|
||||||
TheControlSelection.Remove(LookupRoot);
|
DebugLn(['TMainIDE.CloseUnitComponent freeing component and designer: ',AnUnitInfo.Filename,' ',DbgSName(AnUnitInfo.Component)]);
|
||||||
// free designer and design form
|
OldDesigner.FreeDesigner(true);
|
||||||
OldDesigner.DeleteFormAndFree;
|
AnUnitInfo.Component:=nil;
|
||||||
|
FreeUnusedComponents;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
AnUnitInfo.Component:=nil;
|
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TMainIDE.UnitComponentIsUsed(AnUnitInfo: TUnitInfo;
|
||||||
|
CheckHasDesigner: boolean): boolean;
|
||||||
|
var
|
||||||
|
LookupRoot: TComponent;
|
||||||
|
AForm: TCustomForm;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
LookupRoot:=AnUnitInfo.Component;
|
||||||
|
if LookupRoot=nil then exit;
|
||||||
|
// check if a designer is open
|
||||||
|
if CheckHasDesigner then begin
|
||||||
|
AForm:=FormEditor1.GetDesignerForm(LookupRoot);
|
||||||
|
if AForm<>nil then exit(true);
|
||||||
|
end;
|
||||||
|
// check if another component uses this component
|
||||||
|
if Project1.UnitUsingComponentUnit(AnUnitInfo)<>nil then
|
||||||
|
exit(true);
|
||||||
|
end;
|
||||||
|
|
||||||
function TMainIDE.CreateProjectObject(ProjectDesc,
|
function TMainIDE.CreateProjectObject(ProjectDesc,
|
||||||
FallbackProjectDesc: TProjectDescriptor): TProject;
|
FallbackProjectDesc: TProjectDescriptor): TProject;
|
||||||
begin
|
begin
|
||||||
@ -5657,7 +5705,7 @@ begin
|
|||||||
// the file is not really new
|
// the file is not really new
|
||||||
NewUnitInfo:=AProject.Units[OldUnitIndex];
|
NewUnitInfo:=AProject.Units[OldUnitIndex];
|
||||||
// close form
|
// close form
|
||||||
CloseDesignerForm(NewUnitInfo);
|
CloseUnitComponent(NewUnitInfo);
|
||||||
// assign source
|
// assign source
|
||||||
NewUnitInfo.Source:=NewBuffer;
|
NewUnitInfo.Source:=NewBuffer;
|
||||||
end else
|
end else
|
||||||
@ -5970,7 +6018,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// close form
|
// close form
|
||||||
CloseDesignerForm(ActiveUnitInfo);
|
CloseUnitComponent(ActiveUnitInfo);
|
||||||
|
|
||||||
// close source editor
|
// close source editor
|
||||||
SourceNoteBook.CloseFile(PageIndex);
|
SourceNoteBook.CloseFile(PageIndex);
|
||||||
@ -6042,7 +6090,7 @@ var
|
|||||||
// this is no pascal source and there is a designer form
|
// this is no pascal source and there is a designer form
|
||||||
// This can be the case, when the file is renamed and reverted
|
// This can be the case, when the file is renamed and reverted
|
||||||
// -> close form
|
// -> close form
|
||||||
CloseDesignerForm(NewUnitInfo);
|
CloseUnitComponent(NewUnitInfo);
|
||||||
end;
|
end;
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
@ -9010,7 +9058,7 @@ begin
|
|||||||
while AnUnitInfo<>nil do begin
|
while AnUnitInfo<>nil do begin
|
||||||
NextUnitInfo:=AnUnitInfo.NextUnitWithComponent;
|
NextUnitInfo:=AnUnitInfo.NextUnitWithComponent;
|
||||||
if not AnUnitInfo.NeedsSaveToDisk then
|
if not AnUnitInfo.NeedsSaveToDisk then
|
||||||
CloseDesignerForm(AnUnitInfo);
|
CloseUnitComponent(AnUnitInfo);
|
||||||
AnUnitInfo:=NextUnitInfo;
|
AnUnitInfo:=NextUnitInfo;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -11251,7 +11299,7 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
CloseDesignerForm(AnUnitInfo);
|
CloseUnitComponent(AnUnitInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OnDesignerRenameComponent(ADesigner: TDesigner;
|
procedure TMainIDE.OnDesignerRenameComponent(ADesigner: TDesigner;
|
||||||
|
@ -578,7 +578,9 @@ type
|
|||||||
function ProjectUnitWithUnitname(const AnUnitName: string): TUnitInfo;
|
function ProjectUnitWithUnitname(const AnUnitName: string): TUnitInfo;
|
||||||
function UnitWithEditorIndex(Index:integer): TUnitInfo;
|
function UnitWithEditorIndex(Index:integer): TUnitInfo;
|
||||||
function UnitWithComponent(AComponent: TComponent): TUnitInfo;
|
function UnitWithComponent(AComponent: TComponent): TUnitInfo;
|
||||||
function UnitComponentInheritingFrom(AClass: TComponentClass): TUnitInfo;
|
function UnitComponentInheritingFrom(AClass: TComponentClass;
|
||||||
|
Ignore: TUnitInfo): TUnitInfo;
|
||||||
|
function UnitUsingComponentUnit(ComponentUnit: TUnitInfo): TUnitInfo;
|
||||||
function UnitInfoWithFilename(const AFilename: string): TUnitInfo;
|
function UnitInfoWithFilename(const AFilename: string): TUnitInfo;
|
||||||
function UnitInfoWithFilename(const AFilename: string;
|
function UnitInfoWithFilename(const AFilename: string;
|
||||||
SearchFlags: TProjectFileSearchFlags): TUnitInfo;
|
SearchFlags: TProjectFileSearchFlags): TUnitInfo;
|
||||||
@ -3373,12 +3375,22 @@ begin
|
|||||||
Result:=Result.fNext[uilWithComponent];
|
Result:=Result.fNext[uilWithComponent];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TProject.UnitComponentInheritingFrom(AClass: TComponentClass
|
function TProject.UnitComponentInheritingFrom(AClass: TComponentClass;
|
||||||
): TUnitInfo;
|
Ignore: TUnitInfo): TUnitInfo;
|
||||||
begin
|
begin
|
||||||
Result:=fFirst[uilWithComponent];
|
Result:=fFirst[uilWithComponent];
|
||||||
while (Result<>nil) and (Result.Component.InheritsFrom(AClass)) do
|
while (Result<>nil) do begin
|
||||||
|
if (Result<>Ignore) and Result.Component.InheritsFrom(AClass) then exit;
|
||||||
Result:=Result.fNext[uilWithComponent];
|
Result:=Result.fNext[uilWithComponent];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProject.UnitUsingComponentUnit(ComponentUnit: TUnitInfo): TUnitInfo;
|
||||||
|
begin
|
||||||
|
Result:=nil;
|
||||||
|
if ComponentUnit.Component=nil then exit;
|
||||||
|
Result:=UnitComponentInheritingFrom(
|
||||||
|
TComponentClass(ComponentUnit.Component.ClassType),ComponentUnit);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TProject.UnitInfoWithFilename(const AFilename: string): TUnitInfo;
|
function TProject.UnitInfoWithFilename(const AFilename: string): TUnitInfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user