mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 06:09:30 +02:00
buildintf: added TProjectFileDescriptor.Initialized, IDE: newfile: set HasResources before calling Initialized
This commit is contained in:
parent
595a4673e4
commit
b9cfb64b7b
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user