diff --git a/components/buildintf/projectintf.pas b/components/buildintf/projectintf.pas index d3d54bfac1..21b801cd1a 100644 --- a/components/buildintf/projectintf.pas +++ b/components/buildintf/projectintf.pas @@ -123,6 +123,7 @@ type procedure UpdateDefaultPascalFileExtension(const DefPasExt: string); virtual; function Init(var {%H-}NewFilename: string; {%H-}NewOwner: TObject; var {%H-}NewSource: string; {%H-}Quiet: boolean): TModalResult; virtual; + function Initialized({%H-}NewFile: TLazProjectFile): TModalResult; virtual; // ready to open in source editor public property Owner: TIDEProjPackBase read FOwner write FOwner; // project, package or nil property Name: string read FName write SetName; @@ -1063,6 +1064,12 @@ begin Result:=mrOk; end; +function TProjectFileDescriptor.Initialized(NewFile: TLazProjectFile + ): TModalResult; +begin + Result:=mrOk; +end; + { TFileDescPascalUnit } constructor TFileDescPascalUnit.Create; diff --git a/ide/sourcefilemanager.pas b/ide/sourcefilemanager.pas index 66c0925d33..74cdbc27cd 100644 --- a/ide/sourcefilemanager.pas +++ b/ide/sourcefilemanager.pas @@ -2178,6 +2178,28 @@ begin and (pfMainUnitHasUsesSectionForAllUnits in AProject.Flags)); end; NewSrcEdit := Nil; + + // Update HasResources property (if the .lfm file was created separately) + if (not NewUnitInfo.HasResources) + and FilenameIsPascalUnit(NewUnitInfo.Filename) then begin + //debugln('NewFile no HasResources ',NewUnitInfo.Filename); + LFMFilename:=ChangeFileExt(NewUnitInfo.Filename,'.lfm'); + SearchFlags:=[]; + if NewUnitInfo.IsPartOfProject then + Include(SearchFlags,pfsfOnlyProjectFiles); + if NewUnitInfo.IsVirtual then + Include(SearchFlags,pfsfOnlyVirtualFiles); + if (AProject.UnitInfoWithFilename(LFMFilename,SearchFlags)<>nil) then begin + //debugln('NewFile no HasResources ',NewUnitInfo.Filename,' ResourceFile exists'); + NewUnitInfo.HasResources:=true; + end; + end; + + // call hook + Result:=NewFileDescriptor.Initialized(NewUnitInfo); + if Result<>mrOk then + exit(mrCancel); + if nfOpenInEditor in NewFlags then begin // open a new sourceeditor SrcNoteBook := SourceEditorManager.ActiveOrNewSourceWindow; @@ -2271,22 +2293,6 @@ begin // do not open in editor end; - // Update HasResources property (if the .lfm file was created separately) - if (not NewUnitInfo.HasResources) - and FilenameIsPascalUnit(NewUnitInfo.Filename) then begin - //debugln('NewFile no HasResources ',NewUnitInfo.Filename); - LFMFilename:=ChangeFileExt(NewUnitInfo.Filename,'.lfm'); - SearchFlags:=[]; - if NewUnitInfo.IsPartOfProject then - Include(SearchFlags,pfsfOnlyProjectFiles); - if NewUnitInfo.IsVirtual then - Include(SearchFlags,pfsfOnlyVirtualFiles); - if (AProject.UnitInfoWithFilename(LFMFilename,SearchFlags)<>nil) then begin - //debugln('NewFile no HasResources ',NewUnitInfo.Filename,' ResourceFile exists'); - NewUnitInfo.HasResources:=true; - end; - end; - if (nfAskForFilename in NewFlags) then begin // save and ask for filename NewUnitInfo.Modified:=true;