Merged revision(s) 51059 #42e68fd86d, 51080 #2a49eb46bc, 51084 #0a7cc81dde, 51105 #476bc7e244 from trunk:

IDE: Save Application Bundle and resource XPManifest to default project configuration. Issue #22286.
........
LazBuild: Fix compilation after r51059 #42e68fd86d. Issue #29274.
........
IDE: Enable "Make Resource String" command also when cursor is behind an end-quote. Issue #28829.
........
IDE: Remove explicit update of Messages window from TMainIDE.StartIDE. It deserves no special treatment layout-wise.
........

git-svn-id: branches/fixes_1_6@51148 -
This commit is contained in:
maxim 2016-01-03 12:28:36 +00:00
parent 6e20c18b2d
commit a47a2dffda
10 changed files with 139 additions and 91 deletions

View File

@ -18,10 +18,13 @@ type
{ TAbstractProjectResource } { TAbstractProjectResource }
TAbstractProjectResource = class TAbstractProjectResource = class
protected private
FModified: boolean; FModified: boolean;
FOnModified: TNotifyEvent; FOnModified: TNotifyEvent;
procedure SetModified(const AValue: boolean); procedure SetModified(const AValue: boolean);
protected
// This resource is used when reading project default options.
FIsDefaultOption: Boolean;
public public
constructor Create; virtual; constructor Create; virtual;
@ -33,6 +36,7 @@ type
property Modified: boolean read FModified write SetModified; property Modified: boolean read FModified write SetModified;
property OnModified: TNotifyEvent read FOnModified write FOnModified; property OnModified: TNotifyEvent read FOnModified write FOnModified;
property IsDefaultOption: Boolean read FIsDefaultOption;
end; end;
TAbstractProjectResourceClass = class of TAbstractProjectResource; TAbstractProjectResourceClass = class of TAbstractProjectResource;

View File

@ -974,6 +974,7 @@ type
function GetHighlighterAttriAtRowColEx(XY: TPoint; out Token: string; function GetHighlighterAttriAtRowColEx(XY: TPoint; out Token: string;
out TokenType, Start: Integer; out TokenType, Start: Integer;
out Attri: TSynHighlighterAttributes): boolean; //L505 out Attri: TSynHighlighterAttributes): boolean; //L505
procedure CaretAtIdentOrString(XY: TPoint; out AtIdent, NearString: Boolean);
procedure GetWordBoundsAtRowCol(const XY: TPoint; out StartX, EndX: integer); procedure GetWordBoundsAtRowCol(const XY: TPoint; out StartX, EndX: integer);
function GetWordAtRowCol(XY: TPoint): string; function GetWordAtRowCol(XY: TPoint): string;
function NextTokenPos: TPoint; virtual; deprecated; // use next word pos instead function NextTokenPos: TPoint; virtual; deprecated; // use next word pos instead
@ -8830,8 +8831,7 @@ begin
if (PosX >= Start) and (PosX < Start + Length(Token)) then begin if (PosX >= Start) and (PosX < Start + Length(Token)) then begin
Attri := Highlighter.GetTokenAttribute; Attri := Highlighter.GetTokenAttribute;
TokenType := Highlighter.GetTokenKind; TokenType := Highlighter.GetTokenKind;
Result := TRUE; exit(True);
exit;
end; end;
Highlighter.Next; Highlighter.Next;
end; end;
@ -8840,7 +8840,53 @@ begin
Token := ''; Token := '';
Attri := nil; Attri := nil;
TokenType := -1; TokenType := -1;
Result := FALSE; Result := False;
end;
procedure TCustomSynEdit.CaretAtIdentOrString(XY: TPoint; out AtIdent, NearString: Boolean);
// This is optimized to check if cursor is on identifier or string.
var
PosX, PosY: integer;
Line, Token: string;
Start: Integer;
Attri, PrevAttri: TSynHighlighterAttributes;
begin
PosY := XY.Y -1;
PrevAttri := nil;
AtIdent := False;
NearString := False;
//DebugLn('');
//DebugLn('TCustomSynEdit.CaretAtIdentOrString: Enter');
if Assigned(Highlighter) and (PosY >= 0) and (PosY < FTheLinesView.Count) then
begin
Line := FTheLinesView[PosY];
fHighlighter.CurrentLines := FTheLinesView;
Highlighter.StartAtLineIndex(PosY);
PosX := XY.X;
//DebugLn([' TCustomSynEdit.CaretAtIdentOrString: Line="', Line, '", PosX=', PosX, ', PosY=', PosY]);
if (PosX > 0) and (PosX <= Length(Line)) then
begin
while not Highlighter.GetEol do
begin
Start := Highlighter.GetTokenPos + 1;
Token := Highlighter.GetToken;
//TokenType := Highlighter.GetTokenKind;
Attri := Highlighter.GetTokenAttribute;
//DebugLn([' TCustomSynEdit.CaretAtIdentOrString: Start=', Start, ', Token=', Token]);
if (PosX >= Start) and (PosX < Start + Length(Token)) then
begin
AtIdent := Attri = Highlighter.IdentifierAttribute;
NearString := (Attri = Highlighter.StringAttribute)
or (PrevAttri = Highlighter.StringAttribute); // If cursor is on end-quote.
//DebugLn([' TCustomSynEdit.CaretAtIdentOrString: Success! Attri=', Attri,
// ', AtIdent=', AtIdent, ', AtString=', AtString]);
exit;
end;
PrevAttri := Attri;
Highlighter.Next;
end;
end;
end;
end; end;
function TCustomSynEdit.IdentChars: TSynIdentChars; function TCustomSynEdit.IdentChars: TSynIdentChars;

View File

@ -255,10 +255,13 @@ begin
begin begin
TitleEdit.Text := Title; TitleEdit.Text := Title;
UseAppBundleCheckBox.Checked := UseAppBundle; UseAppBundleCheckBox.Checked := UseAppBundle;
UseXPManifestCheckBox.Checked := TProjectXPManifest(ProjResources[TProjectXPManifest]).UseManifest; with ProjResources.XPManifest do
DpiAwareCheckBox.Checked := TProjectXPManifest(ProjResources[TProjectXPManifest]).DpiAware; begin
ExecutionLevelComboBox.ItemIndex := Ord(TProjectXPManifest(ProjResources[TProjectXPManifest]).ExecutionLevel); UseXPManifestCheckBox.Checked := UseManifest;
UIAccessCheckBox.Checked := TProjectXPManifest(ProjResources[TProjectXPManifest]).UIAccess; DpiAwareCheckBox.Checked := DpiAware;
ExecutionLevelComboBox.ItemIndex := Ord(ExecutionLevel);
UIAccessCheckBox.Checked := UIAccess;
end;
DpiAwareCheckBox.Enabled := UseXPManifestCheckBox.Checked; DpiAwareCheckBox.Enabled := UseXPManifestCheckBox.Checked;
ExecutionLevelLabel.Enabled := UseXPManifestCheckBox.Checked; ExecutionLevelLabel.Enabled := UseXPManifestCheckBox.Checked;
ExecutionLevelComboBox.Enabled := UseXPManifestCheckBox.Checked; ExecutionLevelComboBox.Enabled := UseXPManifestCheckBox.Checked;

View File

@ -1585,7 +1585,6 @@ begin
Application.Terminate; Application.Terminate;
exit; exit;
end; end;
DoShowMessagesView(false); // reopen extra windows
fUserInputSinceLastIdle:=true; // Idle work gets done initially before user action. fUserInputSinceLastIdle:=true; // Idle work gets done initially before user action.
MainIDEBar.ApplicationIsActivate:=true; MainIDEBar.ApplicationIsActivate:=true;
IDECommandList.AddCustomUpdateEvent(@UpdateMainIDECommands); IDECommandList.AddCustomUpdateEvent(@UpdateMainIDECommands);
@ -3625,10 +3624,9 @@ var
Editable: Boolean; Editable: Boolean;
SelAvail: Boolean; SelAvail: Boolean;
SelEditable: Boolean; SelEditable: Boolean;
SrcEditorActive, DsgEditorActive, StringFound, IdentFound: Boolean; SrcEditorActive, DsgEditorActive, IdentFound, StringFound: Boolean;
ActiveDesigner: TComponentEditorDesigner; ActiveDesigner: TComponentEditorDesigner;
xAttr: TSynHighlighterAttributes; CurWordAtCursor: string;
xToken, CurWordAtCursor: string;
begin begin
GetCurrentUnit(ASrcEdit, AnUnitInfo); GetCurrentUnit(ASrcEdit, AnUnitInfo);
if not UpdateEditorCommandsStamp.Changed(ASrcEdit, DisplayState) then if not UpdateEditorCommandsStamp.Changed(ASrcEdit, DisplayState) then
@ -3641,18 +3639,16 @@ begin
DsgEditorActive := DisplayState = dsForm; DsgEditorActive := DisplayState = dsForm;
ActiveDesigner := GetActiveDesignerSkipMainBar; ActiveDesigner := GetActiveDesignerSkipMainBar;
StringFound := False;
IdentFound := False;
CurWordAtCursor := '';
if ASrcEdit<>nil then if ASrcEdit<>nil then
begin begin
CurWordAtCursor := ASrcEdit.GetWordAtCurrentCaret; CurWordAtCursor := ASrcEdit.GetWordAtCurrentCaret;
//it is faster to get information from SynEdit than from CodeTools //it is faster to get information from SynEdit than from CodeTools
if ASrcEdit.EditorComponent.GetHighlighterAttriAtRowCol(ASrcEdit.EditorComponent.CaretXY, xToken, xAttr) then ASrcEdit.EditorComponent.CaretAtIdentOrString(ASrcEdit.EditorComponent.CaretXY, IdentFound, StringFound);
begin end
StringFound := xAttr = ASrcEdit.EditorComponent.Highlighter.StringAttribute; else begin
IdentFound := xAttr = ASrcEdit.EditorComponent.Highlighter.IdentifierAttribute; CurWordAtCursor := '';
end; IdentFound := False;
StringFound := False;
end; end;
if Assigned(ActiveDesigner) then if Assigned(ActiveDesigner) then

View File

@ -817,19 +817,9 @@ begin
AFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectOptionsFilename; AFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectOptionsFilename;
if not FileExistsUTF8(AFilename) then if not FileExistsUTF8(AFilename) then
CopySecondaryConfigFile(DefaultProjectOptionsFilename); CopySecondaryConfigFile(DefaultProjectOptionsFilename);
if FileExistsUTF8(AFilename) then begin if FileExistsUTF8(AFilename) then
if AProject.ReadProject(AFilename,nil,True)<>mrOk then if AProject.ReadProject(AFilename,nil,False)<>mrOk then
DebugLn(['TMainIDEBase.DoLoadDefaultCompilerOptions failed']); DebugLn(['TMainIDEBase.DoLoadDefaultCompilerOptions failed']);
end else begin
// old way (<0.9.31)
// load default compiler options if exists
AFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectCompilerOptionsFilename;
if not FileExistsUTF8(AFilename) then
CopySecondaryConfigFile(DefaultProjectCompilerOptionsFilename);
if not FileExistsUTF8(AFilename) then exit;
if AProject.CompilerOptions.LoadFromFile(AFilename)<>mrOk then
DebugLn(['TMainIDEBase.DoLoadDefaultCompilerOptions failed']);
end;
// change target file name // change target file name
AFilename:=ExtractFileName(AProject.CompilerOptions.TargetFilename); AFilename:=ExtractFileName(AProject.CompilerOptions.TargetFilename);

View File

@ -655,7 +655,7 @@ type
// load, save // load, save
procedure LoadProjOptsFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure LoadProjOptsFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure LoadSessionFromXMLConfig(XMLConfig: TXMLConfig; const Path: string; procedure LoadSessionFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
LoadParts: boolean); LoadAllOptions: boolean);
procedure SaveProjOptsToXMLConfig(XMLConfig: TXMLConfig; const Path: string; procedure SaveProjOptsToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
SaveSession: boolean); SaveSession: boolean);
procedure SaveSessionOptsToXMLConfig(XMLConfig: TXMLConfig; const Path: string; procedure SaveSessionOptsToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
@ -762,7 +762,7 @@ type
FUseAsDefault: Boolean; FUseAsDefault: Boolean;
// Variables used by ReadProject / WriteProject // Variables used by ReadProject / WriteProject
FXMLConfig: TXMLConfig; FXMLConfig: TXMLConfig;
FLoadParts: Boolean; FLoadAllOptions: Boolean; // All options / just options used as default for new projects
FFileVersion: Integer; FFileVersion: Integer;
FNewMainUnitID: LongInt; FNewMainUnitID: LongInt;
FProjectWriteFlags: TProjectWriteFlags; FProjectWriteFlags: TProjectWriteFlags;
@ -888,10 +888,10 @@ type
procedure IgnoreProjectInfoFileOnDisk; procedure IgnoreProjectInfoFileOnDisk;
function ReadProject(const NewProjectInfoFile: string; function ReadProject(const NewProjectInfoFile: string;
GlobalMatrixOptions: TBuildMatrixOptions; GlobalMatrixOptions: TBuildMatrixOptions;
LoadParts: Boolean = False): TModalResult; LoadAllOptions: Boolean = True): TModalResult;
function WriteProject(ProjectWriteFlags: TProjectWriteFlags; function WriteProject(ProjectWriteFlags: TProjectWriteFlags;
const OverrideProjectInfoFile: string; const OverrideProjectInfoFile: string;
GlobalMatrixOptions: TBuildMatrixOptions): TModalResult; GlobalMatrixOptions: TBuildMatrixOptions): TModalResult;
procedure UpdateExecutableType; override; procedure UpdateExecutableType; override;
procedure BackupSession; procedure BackupSession;
procedure RestoreSession; procedure RestoreSession;
@ -2853,7 +2853,6 @@ begin
// automatically fixes broken lpi files. // automatically fixes broken lpi files.
FNewMainUnitID := FXMLConfig.GetValue(Path+'General/MainUnit/Value', 0); FNewMainUnitID := FXMLConfig.GetValue(Path+'General/MainUnit/Value', 0);
Title := FXMLConfig.GetValue(Path+'General/Title/Value', ''); Title := FXMLConfig.GetValue(Path+'General/Title/Value', '');
UseAppBundle := FXMLConfig.GetValue(Path+'General/UseAppBundle/Value', True);
AutoCreateForms := FXMLConfig.GetValue(Path+'General/AutoCreateForms/Value', true); AutoCreateForms := FXMLConfig.GetValue(Path+'General/AutoCreateForms/Value', true);
// fpdoc // fpdoc
@ -2873,9 +2872,6 @@ begin
end; end;
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject E reading comp sets');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject E reading comp sets');{$ENDIF}
// Resources
ProjResources.ReadFromProjectFile(FXMLConfig, Path);
// load custom data // load custom data
LoadStringToStringTree(FXMLConfig,CustomData,Path+'CustomData/'); LoadStringToStringTree(FXMLConfig,CustomData,Path+'CustomData/');
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject update ct boss');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject update ct boss');{$ENDIF}
@ -2911,7 +2907,7 @@ begin
FFileVersion:=FXMLConfig.GetValue(Path+'Version/Value',0); FFileVersion:=FXMLConfig.GetValue(Path+'Version/Value',0);
// load MacroValues and compiler options // load MacroValues and compiler options
BuildModes.LoadSessionFromXMLConfig(FXMLConfig, Path, FLoadParts); BuildModes.LoadSessionFromXMLConfig(FXMLConfig, Path, FLoadAllOptions);
// load defines used for custom options // load defines used for custom options
LoadOtherDefines(Path); LoadOtherDefines(Path);
@ -2928,21 +2924,8 @@ var
PIFile: String; PIFile: String;
begin begin
Result:=mrOk; Result:=mrOk;
if FLoadParts then begin if FLoadAllOptions then
// read only parts of the lpi, keep other values begin
try
FXMLConfig := TCodeBufXMLConfig.CreateWithCache(Filename,true)
except
on E: Exception do begin
IDEMessageDialog(lisUnableToReadLpi,
Format(lisUnableToReadTheProjectInfoFile,[LineEnding,Filename])+LineEnding+E.Message,
mtError, [mbOk]);
Result:=mrCancel;
exit;
end;
end;
end
else begin
// read the whole lpi, clear any old values // read the whole lpi, clear any old values
Clear; Clear;
ProjectInfoFile:=Filename; ProjectInfoFile:=Filename;
@ -2972,6 +2955,20 @@ begin
fLastReadLPIFilename:=PIFile; fLastReadLPIFilename:=PIFile;
fLastReadLPIFileDate:=Now; fLastReadLPIFileDate:=Now;
FNewMainUnitID:=-1; FNewMainUnitID:=-1;
end
else begin
// read only parts of the lpi, keep other values
try
FXMLConfig := TCodeBufXMLConfig.CreateWithCache(Filename,true)
except
on E: Exception do begin
IDEMessageDialog(lisUnableToReadLpi,
Format(lisUnableToReadTheProjectInfoFile,[LineEnding,Filename])+LineEnding+E.Message,
mtError, [mbOk]);
Result:=mrCancel;
exit;
end;
end;
end; end;
try try
@ -2981,8 +2978,11 @@ begin
fCurStorePathDelim:=StorePathDelim; fCurStorePathDelim:=StorePathDelim;
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject C reading values');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject C reading values');{$ENDIF}
FFileVersion:= FXMLConfig.GetValue(ProjOptionsPath+'Version/Value',0); FFileVersion:= FXMLConfig.GetValue(ProjOptionsPath+'Version/Value',0);
if not FLoadParts then UseAppBundle := FXMLConfig.GetValue(ProjOptionsPath+'General/UseAppBundle/Value', True);
if FLoadAllOptions then
LoadFromLPI; LoadFromLPI;
// Resources
ProjResources.ReadFromProjectFile(FXMLConfig, ProjOptionsPath, FLoadAllOptions);
// load MacroValues and compiler options // load MacroValues and compiler options
ClearBuildModes; ClearBuildModes;
BuildModes.LoadProjOptsFromXMLConfig(FXMLConfig, ProjOptionsPath); BuildModes.LoadProjOptsFromXMLConfig(FXMLConfig, ProjOptionsPath);
@ -3033,13 +3033,13 @@ end;
// Method ReadProject itself // Method ReadProject itself
function TProject.ReadProject(const NewProjectInfoFile: string; function TProject.ReadProject(const NewProjectInfoFile: string;
GlobalMatrixOptions: TBuildMatrixOptions; LoadParts: Boolean): TModalResult; GlobalMatrixOptions: TBuildMatrixOptions; LoadAllOptions: Boolean): TModalResult;
begin begin
Result := mrCancel; Result := mrCancel;
BeginUpdate(true); BeginUpdate(true);
try try
BuildModes.FGlobalMatrixOptions := GlobalMatrixOptions; BuildModes.FGlobalMatrixOptions := GlobalMatrixOptions;
FLoadParts := LoadParts; FLoadAllOptions := LoadAllOptions;
// load project lpi file // load project lpi file
Result:=DoLoadLPI(NewProjectInfoFile); Result:=DoLoadLPI(NewProjectInfoFile);
@ -3048,7 +3048,7 @@ begin
// load session file (if available) // load session file (if available)
if (SessionStorage in pssHasSeparateSession) if (SessionStorage in pssHasSeparateSession)
and (CompareFilenames(ProjectInfoFile,ProjectSessionFile)<>0) and (CompareFilenames(ProjectInfoFile,ProjectSessionFile)<>0)
and not FLoadParts then and FLoadAllOptions then
begin begin
Result:=DoLoadSession(ProjectSessionFile); Result:=DoLoadSession(ProjectSessionFile);
if Result<>mrOK then Exit; if Result<>mrOK then Exit;
@ -3195,7 +3195,8 @@ begin
// save lpi to disk // save lpi to disk
//debugln(['TProject.WriteProject ',DbgSName(FXMLConfig),' FCfgFilename=',FCfgFilename]); //debugln(['TProject.WriteProject ',DbgSName(FXMLConfig),' FCfgFilename=',FCfgFilename]);
FXMLConfig.Flush; FXMLConfig.Flush;
Modified:=false; if not (pwfIgnoreModified in FProjectWriteFlags) then
Modified:=false;
if FSaveSessionInLPI then if FSaveSessionInLPI then
SessionModified:=false; SessionModified:=false;
end; end;
@ -3310,8 +3311,12 @@ begin
FSaveSessionInLPI:=(SessFilename='') or (CompareFilenames(SessFilename,CfgFilename)=0); FSaveSessionInLPI:=(SessFilename='') or (CompareFilenames(SessFilename,CfgFilename)=0);
// check if modified // check if modified
if not (pwfIgnoreModified in ProjectWriteFlags) then if pwfIgnoreModified in ProjectWriteFlags then
begin begin
WriteLPI:=true;
WriteLPS:=true;
end
else begin
WriteLPI:=SomeDataModified or (not FileExistsUTF8(CfgFilename)); WriteLPI:=SomeDataModified or (not FileExistsUTF8(CfgFilename));
if (CompareFilenames(ProjectInfoFile,CfgFilename)=0) then if (CompareFilenames(ProjectInfoFile,CfgFilename)=0) then
// save to default lpi // save to default lpi
@ -3325,10 +3330,7 @@ begin
end else begin end else begin
WriteLPS:=WriteLPI or SomeSessionModified or (not FileExistsUTF8(SessFilename)); WriteLPS:=WriteLPI or SomeSessionModified or (not FileExistsUTF8(SessFilename));
end; end;
if (not WriteLPI) and (not WriteLPS) then exit(mrOk); if not (WriteLPI or WriteLPS) then exit(mrOk);
end else begin
WriteLPI:=true;
WriteLPS:=true;
end; end;
//debugln(['TProject.WriteProject WriteLPI=',WriteLPI,' WriteLPS=',WriteLPS,' Modifed=',Modified,' SessionModified=',SessionModified]); //debugln(['TProject.WriteProject WriteLPI=',WriteLPI,' WriteLPS=',WriteLPS,' Modifed=',Modified,' SessionModified=',SessionModified]);
@ -3783,12 +3785,12 @@ end;
function TProject.GetUseManifest: boolean; function TProject.GetUseManifest: boolean;
begin begin
Result:=TProjectXPManifest(ProjResources[TProjectXPManifest]).UseManifest; Result:=ProjResources.XPManifest.UseManifest;
end; end;
procedure TProject.SetUseManifest(AValue: boolean); procedure TProject.SetUseManifest(AValue: boolean);
begin begin
TProjectXPManifest(ProjResources[TProjectXPManifest]).UseManifest:=AValue; ProjResources.XPManifest.UseManifest:=AValue;
end; end;
function TProject.UnitCount:integer; function TProject.UnitCount:integer;
@ -7108,14 +7110,14 @@ begin
end; end;
procedure TProjectBuildModes.LoadSessionFromXMLConfig(XMLConfig: TXMLConfig; procedure TProjectBuildModes.LoadSessionFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string; LoadParts: boolean); const Path: string; LoadAllOptions: boolean);
// Load for session // Load for session
var var
Cnt: Integer; Cnt: Integer;
begin begin
FXMLConfig := XMLConfig; FXMLConfig := XMLConfig;
if not LoadParts then if LoadAllOptions then
// load matrix options // load matrix options
SessionMatrixOptions.LoadFromXMLConfig(FXMLConfig, Path+'BuildModes/SessionMatrixOptions/'); SessionMatrixOptions.LoadFromXMLConfig(FXMLConfig, Path+'BuildModes/SessionMatrixOptions/');
@ -7126,7 +7128,7 @@ begin
LoadAllMacroValues(Path+'MacroValues/', Cnt); LoadAllMacroValues(Path+'MacroValues/', Cnt);
end; end;
if not LoadParts then if LoadAllOptions then
// load what matrix options are enabled in session build modes // load what matrix options are enabled in session build modes
LoadSessionEnabledNonSessionMatrixOptions(Path+'BuildModes/SessionEnabledMatrixOptions/'); LoadSessionEnabledNonSessionMatrixOptions(Path+'BuildModes/SessionEnabledMatrixOptions/');

View File

@ -1260,8 +1260,7 @@ begin
Result := GetLocalizedName + LineEnding+LineEnding + lisApplicationProgramDescriptor; Result := GetLocalizedName + LineEnding+LineEnding + lisApplicationProgramDescriptor;
end; end;
function TProjectApplicationDescriptor.InitProject( function TProjectApplicationDescriptor.InitProject(AProject: TLazProject): TModalResult;
AProject: TLazProject): TModalResult;
var var
NewSource: String; NewSource: String;
MainFile: TLazProjectFile; MainFile: TLazProjectFile;

View File

@ -37,14 +37,22 @@ unit ProjectResources;
interface interface
uses uses
Classes, SysUtils, Contnrs, Controls, LCLProc, LResources, LazFileUtils, // RTL + LCL
Dialogs, AvgLvlTree, Laz2_XMLCfg, resource, reswriter, Classes, SysUtils, Contnrs, resource, reswriter, fgl,
Controls, LCLProc, LResources, Dialogs,
// LazUtils
LazFileUtils, AvgLvlTree, Laz2_XMLCfg,
// Codetools
KeywordFuncLists, BasicCodeTools, CodeToolManager, CodeCache, KeywordFuncLists, BasicCodeTools, CodeToolManager, CodeCache,
// IdeIntf
ProjectIntf, ProjectResourcesIntf, CompOptsIntf, ProjectIntf, ProjectResourcesIntf, CompOptsIntf,
// IDE
LazarusIDEStrConsts, IDEProcs, DialogProcs, LazarusIDEStrConsts, IDEProcs, DialogProcs,
W32Manifest, W32VersionInfo, ProjectIcon, ProjectUserResources; W32Manifest, W32VersionInfo, ProjectIcon, ProjectUserResources;
type type
TResourceList = specialize TFPGObjectList<TAbstractProjectResource>;
{ TProjectResources } { TProjectResources }
TProjectResources = class(TAbstractProjectResources) TProjectResources = class(TAbstractProjectResources)
@ -54,7 +62,7 @@ type
FInModified: Boolean; FInModified: Boolean;
FLrsIncludeAllowed: Boolean; FLrsIncludeAllowed: Boolean;
FResources: TObjectList; FResources: TResourceList;
FSystemResources: TResources; FSystemResources: TResources;
FLazarusResources: TStringList; FLazarusResources: TStringList;
@ -100,7 +108,7 @@ type
function HasLazarusResources: Boolean; function HasLazarusResources: Boolean;
procedure WriteToProjectFile(AConfig: TXMLConfig; Path: String); procedure WriteToProjectFile(AConfig: TXMLConfig; Path: String);
procedure ReadFromProjectFile(AConfig: TXMLConfig; Path: String); procedure ReadFromProjectFile(AConfig: TXMLConfig; Path: String; ReadAll: Boolean);
property Modified: Boolean read FModified write SetModified; property Modified: Boolean read FModified write SetModified;
property OnModified: TNotifyEvent read FOnModified write FOnModified; property OnModified: TNotifyEvent read FOnModified write FOnModified;
@ -377,7 +385,7 @@ begin
if not FModified then if not FModified then
begin begin
for i := 0 to FResources.Count - 1 do for i := 0 to FResources.Count - 1 do
TAbstractProjectResource(FResources[i]).Modified := False; FResources[i].Modified := False;
end; end;
if Assigned(FOnModified) then if Assigned(FOnModified) then
OnModified(Self); OnModified(Self);
@ -388,16 +396,14 @@ end;
function TProjectResources.Update: Boolean; function TProjectResources.Update: Boolean;
var var
i: integer; i: integer;
Res: TAbstractProjectResource;
begin begin
Result:=true; Result:=true;
Clear; Clear;
for i := 0 to FResources.Count - 1 do for i := 0 to FResources.Count - 1 do
begin begin
Res:=TAbstractProjectResource(FResources[i]); Result := FResources[i].UpdateResources(Self, resFileName);
Result := Res.UpdateResources(Self, resFileName);
if not Result then begin if not Result then begin
debugln(['TProjectResources.Update UpdateResources of ',DbgSName(Res),' failed']); debugln(['TProjectResources.Update UpdateResources of ',DbgSName(FResources[i]),' failed']);
Exit; Exit;
end; end;
end; end;
@ -423,7 +429,7 @@ begin
FSystemResources := TResources.Create; FSystemResources := TResources.Create;
FLazarusResources := TStringList.Create; FLazarusResources := TStringList.Create;
FResources := TObjectList.Create; FResources := TResourceList.Create;
L := GetRegisteredResources; L := GetRegisteredResources;
for i := 0 to L.Count - 1 do for i := 0 to L.Count - 1 do
begin begin
@ -470,7 +476,7 @@ var
begin begin
for i := 0 to FResources.Count - 1 do for i := 0 to FResources.Count - 1 do
begin begin
Result := TAbstractProjectResource(FResources[i]); Result := FResources[i];
if Result.InheritsFrom(AIndex) then if Result.InheritsFrom(AIndex) then
Exit; Exit;
end; end;
@ -482,7 +488,7 @@ var
i: integer; i: integer;
begin begin
for i := 0 to FResources.Count - 1 do for i := 0 to FResources.Count - 1 do
TAbstractProjectResource(FResources[i]).DoAfterBuild(Self, AReason, SaveToTestDir); FResources[i].DoAfterBuild(Self, AReason, SaveToTestDir);
end; end;
procedure TProjectResources.DoBeforeBuild(AReason: TCompileReason; SaveToTestDir: boolean); procedure TProjectResources.DoBeforeBuild(AReason: TCompileReason; SaveToTestDir: boolean);
@ -490,7 +496,7 @@ var
i: integer; i: integer;
begin begin
for i := 0 to FResources.Count - 1 do for i := 0 to FResources.Count - 1 do
TAbstractProjectResource(FResources[i]).DoBeforeBuild(Self, AReason, SaveToTestDir); FResources[i].DoBeforeBuild(Self, AReason, SaveToTestDir);
end; end;
procedure TProjectResources.Clear; procedure TProjectResources.Clear;
@ -558,16 +564,17 @@ var
begin begin
AConfig.SetDeleteValue(Path+'General/ResourceType/Value', ResourceTypeNames[ResourceType], ResourceTypeNames[rtLRS]); AConfig.SetDeleteValue(Path+'General/ResourceType/Value', ResourceTypeNames[ResourceType], ResourceTypeNames[rtLRS]);
for i := 0 to FResources.Count - 1 do for i := 0 to FResources.Count - 1 do
TAbstractProjectResource(FResources[i]).WriteToProjectFile(AConfig, Path); FResources[i].WriteToProjectFile(AConfig, Path);
end; end;
procedure TProjectResources.ReadFromProjectFile(AConfig: TXMLConfig; Path: String); procedure TProjectResources.ReadFromProjectFile(AConfig: TXMLConfig; Path: String; ReadAll: Boolean);
var var
i: integer; i: integer;
begin begin
ResourceType := StrToResourceType(AConfig.GetValue(Path+'General/ResourceType/Value', ResourceTypeNames[rtLRS])); ResourceType := StrToResourceType(AConfig.GetValue(Path+'General/ResourceType/Value', ResourceTypeNames[rtLRS]));
for i := 0 to FResources.Count - 1 do for i := 0 to FResources.Count - 1 do
TAbstractProjectResource(FResources[i]).ReadFromProjectFile(AConfig, Path); if ReadAll or FResources[i].IsDefaultOption then
FResources[i].ReadFromProjectFile(AConfig, Path);
end; end;
function TProjectResources.UpdateMainSourceFile(const AFileName: string): Boolean; function TProjectResources.UpdateMainSourceFile(const AFileName: string): Boolean;

View File

@ -3601,7 +3601,7 @@ begin
// read project info file // read project info file
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TLazSourceFileManager.InitOpenedProjectFile B3');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TLazSourceFileManager.InitOpenedProjectFile B3');{$ENDIF}
Project1.ReadProject(AFilename,EnvironmentOptions.BuildMatrixOptions); Project1.ReadProject(AFilename, EnvironmentOptions.BuildMatrixOptions, True);
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TLazSourceFileManager.InitOpenedProjectFile B4');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TLazSourceFileManager.InitOpenedProjectFile B4');{$ENDIF}
Result:=CompleteLoadingProjectInfo; Result:=CompleteLoadingProjectInfo;
finally finally
@ -3626,7 +3626,7 @@ begin
// restore files // restore files
while EditorInfoIndex < Project1.AllEditorsInfoCount do begin while EditorInfoIndex < Project1.AllEditorsInfoCount do begin
// TProject.ReadProject sorts alle UnitEditorInfos // TProject.ReadProject sorts all UnitEditorInfos
AnEditorInfo := Project1.AllEditorsInfo[EditorInfoIndex]; AnEditorInfo := Project1.AllEditorsInfo[EditorInfoIndex];
AnUnitInfo := AnEditorInfo.UnitInfo; AnUnitInfo := AnEditorInfo.UnitInfo;
if (not AnUnitInfo.Loaded) or (AnEditorInfo.PageIndex < 0) then begin if (not AnUnitInfo.Loaded) or (AnEditorInfo.PageIndex < 0) then begin

View File

@ -152,6 +152,7 @@ end;
constructor TProjectXPManifest.Create; constructor TProjectXPManifest.Create;
begin begin
inherited Create; inherited Create;
FIsDefaultOption := True;
UseManifest := False; UseManifest := False;
DpiAware := False; DpiAware := False;
ExecutionLevel := xmelAsInvoker; ExecutionLevel := xmelAsInvoker;