startlazarus: wait for initial lazarus to exit, before checking for accepting lazarus

git-svn-id: branches/fixes_2_0@64278 -
This commit is contained in:
mattias 2020-12-26 11:55:15 +00:00
parent 3e0f2f5e68
commit 69c095d1e2
3 changed files with 29 additions and 9 deletions

View File

@ -136,10 +136,10 @@ type
FShowSplashOption: boolean;
function RenameLazarusExecutable(const Directory: string): TModalResult;
procedure LazarusProcessStart(Sender: TObject);
procedure WaitForLazarus;
public
destructor Destroy; override;
procedure Initialize;
procedure WaitForLazarus;
procedure Run;
procedure ShowSplash;
property ShowSplashOption: boolean read FShowSplashOption write FShowSplashOption;
@ -274,6 +274,16 @@ begin
end;
procedure TLazarusManager.Run;
procedure AddExpandedParam(Params: TStringListUTF8; Param: string);
begin
// skip startlazarus params
if LeftStr(Param,length(StartLazarusPidOpt))=StartLazarusPidOpt then
exit;
// expand filenames and append
Params.Add(ExpandParamFile(Param));
end;
var
Restart: boolean;
DefaultDir: String;
@ -286,7 +296,6 @@ var
Params: TStringListUTF8;
i: Integer;
begin
WaitForLazarus;
try
StartPath:=ExpandFileNameUTF8(ParamStrUTF8(0));
if FileIsSymlink(StartPath) then
@ -402,7 +411,7 @@ begin
Params.Add(NoSplashScreenOptLong);
Params.Add(StartedByStartLazarusOpt);
for i:=0 to FCmdLineParams.Count-1 do
Params.Add(ExpandParamFile(FCmdLineParams[i]));
AddExpandedParam(Params,FCmdLineParams[i]);
FLazarusProcess.Process.Parameters.AddStrings(Params);
finally
Params.Free;

View File

@ -50,6 +50,7 @@
<Unit0>
<Filename Value="startlazarus.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="StartLazarus"/>
</Unit0>
<Unit1>
<Filename Value="lazarusmanager.pas"/>

View File

@ -45,12 +45,22 @@ var
begin
redirect_stderr.DoShowWindow := False;
Application.Initialize;
LazIDEInstances.PerformCheck;
if not LazIDEInstances.StartIDE then
Exit;
ALazarusManager := TLazarusManager.Create(nil);
ALazarusManager.Initialize;
ALazarusManager.Run;
FreeAndNil(ALazarusManager);
try
// parse params
ALazarusManager.Initialize;
// if started by lazarus, wait for it to exit
ALazarusManager.WaitForLazarus;
// if there is a lazarus instance accepting files, pass files to that
LazIDEInstances.PerformCheck;
if not LazIDEInstances.StartIDE then
Exit;
// start lazarus
ALazarusManager.Run;
finally
FreeAndNil(ALazarusManager);
end;
end.