mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-21 22:39:30 +02:00
MG: fixed loading program file bug
git-svn-id: trunk@247 -
This commit is contained in:
parent
751a6f677e
commit
0ffbcd9238
28
ide/main.pp
28
ide/main.pp
@ -2163,7 +2163,7 @@ end;
|
||||
function TMainIDE.DoViewUnitsAndForms(OnlyForms: boolean): TModalResult;
|
||||
var UnitList: TList;
|
||||
i, ProgramNameStart, ProgramNameEnd:integer;
|
||||
MainUnitName: string;
|
||||
MainUnitName, Ext: string;
|
||||
MainUnitInfo, AnUnitInfo: TUnitInfo;
|
||||
MainUnitIndex: integer;
|
||||
Begin
|
||||
@ -2173,11 +2173,13 @@ Begin
|
||||
for i:=0 to Project.UnitCount-1 do begin
|
||||
if Project.Units[i].IsPartOfProject then begin
|
||||
if OnlyForms then begin
|
||||
if Project.MainUnit=i then MainUnitIndex:=i;
|
||||
if Project.Units[i].FormName<>'' then
|
||||
UnitList.Add(TViewUnitsEntry.Create(
|
||||
Project.Units[i].FormName,i,false));
|
||||
end else begin
|
||||
if Project.Units[i].UnitName<>'' then begin
|
||||
if Project.MainUnit=i then MainUnitIndex:=i;
|
||||
UnitList.Add(TViewUnitsEntry.Create(
|
||||
Project.Units[i].UnitName,i,false));
|
||||
end else if Project.MainUnit=i then begin
|
||||
@ -2191,6 +2193,11 @@ Begin
|
||||
MainUnitName:=FindProgramNameInSource(MainUnitInfo.Source.Source
|
||||
,ProgramNameStart,ProgramNameEnd);
|
||||
end;
|
||||
if MainUnitName='' then begin
|
||||
MainUnitName:=ExtractFileName(MainUnitInfo.Filename);
|
||||
Ext:=ExtractFileExt(MainUnitName);
|
||||
MainUnitName:=copy(MainUnitName,1,length(MainUnitName)-length(Ext));
|
||||
end;
|
||||
if MainUnitName<>'' then begin
|
||||
MainUnitIndex:=UnitList.Count;
|
||||
UnitList.Add(TViewUnitsEntry.Create(
|
||||
@ -2446,6 +2453,8 @@ end;
|
||||
function TMainIDE.DoOpenProjectFile(AFileName:string):TModalResult;
|
||||
var Ext,AText,ACaption,LPIFilename:string;
|
||||
LowestEditorIndex,LowestUnitIndex,LastEditorIndex,i:integer;
|
||||
SrcStream: TMemoryStream;
|
||||
NewSource: string;
|
||||
begin
|
||||
writeln('TMainIDE.DoOpenProjectFile 1');
|
||||
Result:=mrCancel;
|
||||
@ -2483,6 +2492,20 @@ writeln('TMainIDE.DoOpenProjectFile 1');
|
||||
LPIFilename:=ChangeFileExt(AFilename,'.lpi');
|
||||
Project:=TProject.Create(ptProgram);
|
||||
Project.ReadProject(LPIFilename);
|
||||
if Project.MainUnit=0 then begin
|
||||
// read MainUnit Source
|
||||
SrcStream:=TMemoryStream.Create;
|
||||
try
|
||||
Result:=DoLoadMemoryStreamFromFile(SrcStream
|
||||
,ChangeFileExt(AFilename,'.lpr'));
|
||||
if Result=mrAbort then exit;
|
||||
SetLength(NewSource,SrcStream.Size);
|
||||
SrcStream.Read(NewSource[1],length(NewSource));
|
||||
Project.Units[Project.MainUnit].Source.Source:=NewSource;
|
||||
finally
|
||||
SrcStream.Free;
|
||||
end;
|
||||
end;
|
||||
UpdateCaption;
|
||||
// restore files
|
||||
LastEditorIndex:=-1;
|
||||
@ -3201,6 +3224,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.85 2001/03/29 13:11:33 lazarus
|
||||
MG: fixed loading program file bug
|
||||
|
||||
Revision 1.84 2001/03/29 12:38:59 lazarus
|
||||
MG: new environment opts, ptApplication bugfixes
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user