mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 20:10:20 +02:00
added default session if no lps file found
git-svn-id: trunk@9076 -
This commit is contained in:
parent
afd0d47005
commit
7072bbe773
102
ide/project.pp
102
ide/project.pp
@ -1902,6 +1902,31 @@ var
|
|||||||
FJumpHistory.LoadFromXMLConfig(xmlconfig,Path+'');
|
FJumpHistory.LoadFromXMLConfig(xmlconfig,Path+'');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LoadDefaultSession;
|
||||||
|
var
|
||||||
|
AnUnitInfo: TUnitInfo;
|
||||||
|
BestUnitInfo: TUnitInfo;
|
||||||
|
begin
|
||||||
|
if FirstUnitWithEditorIndex<>nil then exit;
|
||||||
|
|
||||||
|
AnUnitInfo:=FirstPartOfProject;
|
||||||
|
BestUnitInfo:=nil;
|
||||||
|
while AnUnitInfo<>nil do begin
|
||||||
|
if (BestUnitInfo=nil)
|
||||||
|
or (FilenameIsPascalUnit(AnUnitInfo.Filename)
|
||||||
|
and (not FilenameIsPascalUnit(BestUnitInfo.Filename)))
|
||||||
|
then begin
|
||||||
|
BestUnitInfo:=AnUnitInfo;
|
||||||
|
end;
|
||||||
|
AnUnitInfo:=AnUnitInfo.NextPartOfProject;
|
||||||
|
end;
|
||||||
|
if BestUnitInfo<>nil then begin
|
||||||
|
BestUnitInfo.EditorIndex:=0;
|
||||||
|
ActiveEditorIndexAtStart:=0;
|
||||||
|
BestUnitInfo.Loaded:=true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Path: String;
|
Path: String;
|
||||||
xmlconfig: TXMLConfig;
|
xmlconfig: TXMLConfig;
|
||||||
@ -1983,45 +2008,48 @@ begin
|
|||||||
|
|
||||||
// load session file (if available)
|
// load session file (if available)
|
||||||
if (SessionStorage in [pssInProjectDir,pssInIDEConfig])
|
if (SessionStorage in [pssInProjectDir,pssInIDEConfig])
|
||||||
and (CompareFilenames(ProjectInfoFile,ProjectSessionFile)<>0)
|
and (CompareFilenames(ProjectInfoFile,ProjectSessionFile)<>0) then begin
|
||||||
and FileExists(ProjectSessionFile) then begin
|
if FileExists(ProjectSessionFile) then begin
|
||||||
//DebugLn('TProject.ReadProject loading Session ProjectSessionFile=',ProjectSessionFile);
|
//DebugLn('TProject.ReadProject loading Session ProjectSessionFile=',ProjectSessionFile);
|
||||||
try
|
|
||||||
xmlconfig := TXMLConfig.Create(ProjectSessionFile);
|
|
||||||
|
|
||||||
Path:='ProjectSession/';
|
|
||||||
fPathDelimChanged:=
|
|
||||||
XMLConfig.GetValue(Path+'PathDelim/Value', PathDelim)<>PathDelim;
|
|
||||||
|
|
||||||
FileVersion:= XMLConfig.GetValue(Path+'Version/Value',0);
|
|
||||||
|
|
||||||
// load session info
|
|
||||||
LoadSessionInfo(XMLConfig,Path,true);
|
|
||||||
|
|
||||||
// call hooks to read their info (e.g. DebugBoss)
|
|
||||||
if Assigned(OnLoadProjectInfo) then begin
|
|
||||||
OnLoadProjectInfo(Self,XMLConfig,true);
|
|
||||||
end;
|
|
||||||
except
|
|
||||||
MessageDlg('Unable to read the project info file'#13'"'+ProjectInfoFile+'".'
|
|
||||||
,mtError,[mbOk],0);
|
|
||||||
Result:=mrCancel;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
try
|
|
||||||
Path:='ProjectOptions/';
|
|
||||||
fPathDelimChanged:=
|
|
||||||
XMLConfig.GetValue(Path+'PathDelim/Value', PathDelim)<>PathDelim;
|
|
||||||
finally
|
|
||||||
fPathDelimChanged:=false;
|
|
||||||
try
|
try
|
||||||
xmlconfig.Free;
|
xmlconfig := TXMLConfig.Create(ProjectSessionFile);
|
||||||
except
|
|
||||||
end;
|
|
||||||
xmlconfig:=nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
Path:='ProjectSession/';
|
||||||
|
fPathDelimChanged:=
|
||||||
|
XMLConfig.GetValue(Path+'PathDelim/Value', PathDelim)<>PathDelim;
|
||||||
|
|
||||||
|
FileVersion:= XMLConfig.GetValue(Path+'Version/Value',0);
|
||||||
|
|
||||||
|
// load session info
|
||||||
|
LoadSessionInfo(XMLConfig,Path,true);
|
||||||
|
|
||||||
|
// call hooks to read their info (e.g. DebugBoss)
|
||||||
|
if Assigned(OnLoadProjectInfo) then begin
|
||||||
|
OnLoadProjectInfo(Self,XMLConfig,true);
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
MessageDlg('Unable to read the project info file'#13'"'+ProjectInfoFile+'".'
|
||||||
|
,mtError,[mbOk],0);
|
||||||
|
Result:=mrCancel;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
try
|
||||||
|
Path:='ProjectOptions/';
|
||||||
|
fPathDelimChanged:=
|
||||||
|
XMLConfig.GetValue(Path+'PathDelim/Value', PathDelim)<>PathDelim;
|
||||||
|
finally
|
||||||
|
fPathDelimChanged:=false;
|
||||||
|
try
|
||||||
|
xmlconfig.Free;
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
xmlconfig:=nil;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
// there is no .ps file -> create some defaults
|
||||||
|
LoadDefaultSession;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
|
Loading…
Reference in New Issue
Block a user