diff --git a/components/ideintf/lazideintf.pas b/components/ideintf/lazideintf.pas index 74119195f7..734337708c 100644 --- a/components/ideintf/lazideintf.pas +++ b/components/ideintf/lazideintf.pas @@ -578,16 +578,15 @@ type function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; virtual; abstract; public function AutoSizeInShowDesigner(AControl: TControl): Boolean; virtual; abstract; + function GetDesigner(ASourceEditor: TSourceEditorInterface; ATabDisplayState: TTabDisplayState): TIDesigner; virtual; procedure ToggleFormUnit; virtual; abstract; procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); virtual; abstract; - - property TabDisplayState: TTabDisplayState read GetTabDisplayState; - property TabDisplayStateEditor[Index: TSourceEditorInterface]: TTabDisplayState read GetTabDisplayStateEditor; - procedure ShowCode(ASourceEditor: TSourceEditorInterface); virtual; abstract; procedure ShowDesigner(ASourceEditor: TSourceEditorInterface; AIndex: Integer = 0); virtual; abstract; - procedure ShowForm(AForm: TCustomForm); virtual; abstract; + public + property TabDisplayState: TTabDisplayState read GetTabDisplayState; + property TabDisplayStateEditor[Index: TSourceEditorInterface]: TTabDisplayState read GetTabDisplayStateEditor; end; var @@ -626,6 +625,19 @@ begin BootHandlers[ht][i](); end; +{ TIDETabMaster } + +function TIDETabMaster.GetDesigner(ASourceEditor: TSourceEditorInterface; + ATabDisplayState: TTabDisplayState): TIDesigner; +begin + case ATabDisplayState of + tdsDesign: + Result := ASourceEditor.GetDesigner(True); + else + Result := nil; + end; +end; + { TLazIDEInterface } procedure TLazIDEInterface.AddHandler(HandlerType: TLazarusIDEHandlerType; diff --git a/ide/main.pp b/ide/main.pp index 31019cebb8..5a558b0fab 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -2533,14 +2533,13 @@ var function TryGetDesignerFromForm(AForm: TCustomForm; out ADesigner: TComponentEditorDesigner): Boolean; begin - if Assigned(IDETabMaster) and (AForm is TSourceEditorWindowInterface) - and (IDETabMaster.TabDisplayState=tdsDesign) - then - ADesigner := TComponentEditorDesigner(TSourceEditorWindowInterface(AForm). - ActiveEditor.GetDesigner(True)) + if Assigned(IDETabMaster) and (AForm is TSourceEditorWindowInterface) then + ADesigner := TComponentEditorDesigner( + IDETabMaster.GetDesigner( + TSourceEditorWindowInterface(AForm).ActiveEditor, + IDETabMaster.TabDisplayState)) else ADesigner := nil; - Result := ADesigner <> nil; end; @@ -3964,6 +3963,8 @@ var begin GetCurrentUnit(ASrcEdit, AnUnitInfo); ActiveDesigner := GetActiveDesignerSkipMainBar; + if not (ActiveDesigner is TDesigner) then + Exit; if not UpdateEditorCommandsStamp.Changed(ASrcEdit, ActiveDesigner as TDesigner, DisplayState) then Exit;