diff --git a/designer/jitforms.pp b/designer/jitforms.pp index f47ae67724..3db9caf651 100644 --- a/designer/jitforms.pp +++ b/designer/jitforms.pp @@ -670,6 +670,7 @@ begin DoFinishReading; finally UnregisterFindGlobalComponentProc(@MyFindGlobalComponent); + Application.FindGlobalComponentEnabled:=true; if DestroyDriver then Reader.Driver.Free; Reader.Free; end; @@ -697,6 +698,7 @@ begin Reader:=CreateLRSReader(BinStream,DestroyDriver); MyFindGlobalComponentProc:=@OnFindGlobalComponent; RegisterFindGlobalComponentProc(@MyFindGlobalComponent); + Application.FindGlobalComponentEnabled:=false; {$IFDEF VerboseJITForms} writeln('[TJITComponentList.InitReading] A'); @@ -867,6 +869,7 @@ begin DoFinishReading; finally UnregisterFindGlobalComponentProc(@MyFindGlobalComponent); + Application.FindGlobalComponentEnabled:=true; if DestroyDriver then Reader.Driver.Free; Reader.Free; end; diff --git a/lcl/forms.pp b/lcl/forms.pp index a6a35e0bc6..8f8dcf2be6 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -857,6 +857,7 @@ type private FApplicationHandlers: array[TApplicationHandlerType] of TMethodList; FCaptureExceptions: boolean; + FFindGlobalComponentEnabled: boolean; FFlags: TApplicationFlags; FHint: string; FHintColor: TColor; @@ -997,6 +998,8 @@ type procedure DoTabKey(AControl: TWinControl; var Key: Word;Shift: TShiftState); property CaptureExceptions: boolean read FCaptureExceptions write SetCaptureExceptions; + property FindGlobalComponentEnabled: boolean read FFindGlobalComponentEnabled + write FFindGlobalComponentEnabled; //property HelpSystem : IHelpSystem read FHelpSystem; property Hint: string read FHint write SetHint; property HintColor: TColor read FHintColor write SetHintColor; diff --git a/lcl/include/application.inc b/lcl/include/application.inc index 7124e5818b..ae36eeacd5 100644 --- a/lcl/include/application.inc +++ b/lcl/include/application.inc @@ -27,7 +27,10 @@ const function FindApplicationComponent(const ComponentName: string): TComponent; begin - Result:=Application.FindComponent(ComponentName); + if Application.FindGlobalComponentEnabled then + Result:=Application.FindComponent(ComponentName) + else + Result:=nil; end; function GetHintControl(Control: TControl): TControl; @@ -93,6 +96,8 @@ begin ApplicationActionComponent:=Self; OnMenuPopupHandler:=@MenuPopupHandler; + FFindGlobalComponentEnabled:=true; + RegisterFindGlobalComponentProc(@FindApplicationComponent); inherited Create(AOwner); CaptureExceptions:=true; @@ -132,6 +137,9 @@ begin for HandlerType:=Low(TApplicationHandlerType) to High(TApplicationHandlerType) do FreeThenNil(FApplicationHandlers[HandlerType]); + + UnregisterFindGlobalComponentProc(@FindApplicationComponent); + inherited Destroy; Include(FFlags,AppDoNotReleaseComponents); @@ -1414,7 +1422,6 @@ begin // events and constructors can refer to it TComponent(Reference) := Instance; - RegisterFindGlobalComponentProc(@FindApplicationComponent); ok:=false; try Instance.Create(Self); @@ -1422,7 +1429,6 @@ begin finally if not ok then TComponent(Reference) := nil; - UnregisterFindGlobalComponentProc(@FindApplicationComponent); end; if (Instance is TForm) then begin