mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-09 03:37:20 +01:00
LCL: fixed FindApplicationComponent to ignore designer forms
git-svn-id: trunk@26052 -
This commit is contained in:
parent
7e4e55bc52
commit
6669dc093d
@ -982,7 +982,9 @@ type
|
||||
function GetCurrentModalForm: TCustomForm;
|
||||
function GetCurrentModalFormZIndex: Integer;
|
||||
function CustomFormBelongsToActiveGroup(AForm: TCustomForm): Boolean;
|
||||
function FindNonDesignerForm(const FormName: string): TCustomForm;
|
||||
function FindForm(const FormName: string): TCustomForm;
|
||||
function FindNonDesignerDataModule(const DataModuleName: string): TDataModule;
|
||||
function FindDataModule(const DataModuleName: string): TDataModule;
|
||||
procedure UpdateScreen;
|
||||
// handler
|
||||
|
||||
@ -20,14 +20,16 @@
|
||||
{ $define DebugHintWindow}
|
||||
|
||||
function FindApplicationComponent(const ComponentName: string): TComponent;
|
||||
// Note: this function is used by TReader to auto rename forms to unique names.
|
||||
begin
|
||||
if Application.FindGlobalComponentEnabled then
|
||||
begin
|
||||
// ignore designer forms (the IDE registers its own functions to handle them)
|
||||
Result:=Application.FindComponent(ComponentName);
|
||||
if Result=nil then
|
||||
Result:=Screen.FindForm(ComponentName);
|
||||
Result:=Screen.FindNonDesignerForm(ComponentName);
|
||||
if Result=nil then
|
||||
Result:=Screen.FindDataModule(ComponentName);
|
||||
Result:=Screen.FindNonDesignerDataModule(ComponentName);
|
||||
end
|
||||
else
|
||||
Result:=nil;
|
||||
|
||||
@ -218,6 +218,20 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TScreen.FindNonDesignerForm(const FormName: string): TCustomForm;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to FCustomForms.Count - 1 do
|
||||
begin
|
||||
Result:=TCustomForm(FCustomForms[i]);
|
||||
if (not (csDesigning in Result.ComponentState))
|
||||
and (CompareText(Result.Name, FormName) = 0) then
|
||||
exit;
|
||||
end;
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TScreen.FindForm(const FormName: string): TCustomForm;
|
||||
var
|
||||
i: Integer;
|
||||
@ -228,16 +242,31 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TScreen.FindNonDesignerDataModule(const DataModuleName: string
|
||||
): TDataModule;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to FDataModuleList.Count-1 do
|
||||
begin
|
||||
Result:=TDataModule(FDataModuleList[i]);
|
||||
if (not (csDesigning in Result.ComponentState))
|
||||
and (CompareText(Result.Name, DataModuleName) = 0) then
|
||||
Exit;
|
||||
end;
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TScreen.FindDataModule(const DataModuleName: string): TDataModule;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to FDataModuleList.Count-1 do
|
||||
if CompareText(TDataModule(FDataModuleList[i]).Name, DataModuleName) = 0 then
|
||||
begin
|
||||
Result := TDataModule(FDataModuleList[i]);
|
||||
begin
|
||||
Result:=TDataModule(FDataModuleList[i]);
|
||||
if (CompareText(Result.Name, DataModuleName) = 0) then
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user